main.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. ---
  2. # input variables:
  3. # - l_docker_upgrade
  4. # - openshift.common.is_atomic
  5. # - node_config_hook
  6. # - openshift_pkg_version
  7. # - openshift.common.is_containerized
  8. # - deployment_type
  9. # - openshift_release
  10. # tasks file for openshift_node_upgrade
  11. - name: Stop node and openvswitch services
  12. service:
  13. name: "{{ item }}"
  14. state: stopped
  15. with_items:
  16. - "{{ openshift.common.service_type }}-node"
  17. - openvswitch
  18. failed_when: false
  19. - name: Stop additional containerized services
  20. service:
  21. name: "{{ item }}"
  22. state: stopped
  23. with_items:
  24. - "{{ openshift.common.service_type }}-master-controllers"
  25. - "{{ openshift.common.service_type }}-master-api"
  26. - etcd_container
  27. failed_when: false
  28. when: openshift.common.is_containerized | bool
  29. - name: Pre-pull node image
  30. command: >
  31. docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }}
  32. register: pull_result
  33. changed_when: "'Downloaded newer image' in pull_result.stdout"
  34. when: openshift.common.is_containerized | bool
  35. - name: Pre-pull openvswitch image
  36. command: >
  37. docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }}
  38. register: pull_result
  39. changed_when: "'Downloaded newer image' in pull_result.stdout"
  40. when:
  41. - openshift.common.is_containerized | bool
  42. - openshift_use_openshift_sdn | bool
  43. - include: docker/upgrade.yml
  44. vars:
  45. # We will restart Docker ourselves after everything is ready:
  46. skip_docker_restart: True
  47. when:
  48. - l_docker_upgrade is defined
  49. - l_docker_upgrade | bool
  50. - include: "{{ node_config_hook }}"
  51. when: node_config_hook is defined
  52. - include: rpm_upgrade.yml
  53. vars:
  54. component: "node"
  55. openshift_version: "{{ openshift_pkg_version | default('') }}"
  56. when: not openshift.common.is_containerized | bool
  57. - name: Remove obsolete docker-sdn-ovs.conf
  58. file:
  59. path: "/etc/systemd/system/docker.service.d/docker-sdn-ovs.conf"
  60. state: absent
  61. when: (deployment_type == 'openshift-enterprise' and openshift_release | version_compare('3.4', '>='))
  62. or (deployment_type == 'origin' and openshift_release | version_compare('1.4', '>='))
  63. - include: containerized_node_upgrade.yml
  64. when: openshift.common.is_containerized | bool
  65. - name: Ensure containerized services stopped before Docker restart
  66. service:
  67. name: "{{ item }}"
  68. state: stopped
  69. with_items:
  70. - etcd_container
  71. - openvswitch
  72. - "{{ openshift.common.service_type }}-master-api"
  73. - "{{ openshift.common.service_type }}-master-controllers"
  74. - "{{ openshift.common.service_type }}-node"
  75. failed_when: false
  76. when: openshift.common.is_containerized | bool
  77. - name: Stop rpm based services
  78. service:
  79. name: "{{ item }}"
  80. state: stopped
  81. with_items:
  82. - "{{ openshift.common.service_type }}-node"
  83. - openvswitch
  84. failed_when: false
  85. when: not openshift.common.is_containerized | bool
  86. - name: Upgrade openvswitch
  87. package:
  88. name: openvswitch
  89. state: latest
  90. when: not openshift.common.is_containerized | bool
  91. - name: Update oreg value
  92. yedit:
  93. src: "{{ openshift.common.config_base }}/node/node-config.yaml"
  94. key: 'imageConfig.format'
  95. value: "{{ oreg_url | default(oreg_url_node) }}"
  96. when: oreg_url is defined or oreg_url_node is defined
  97. # https://docs.openshift.com/container-platform/3.4/admin_guide/overcommit.html#disabling-swap-memory
  98. - name: Check for swap usage
  99. command: grep "^[^#].*swap" /etc/fstab
  100. # grep: match any lines which don't begin with '#' and contain 'swap'
  101. changed_when: false
  102. failed_when: false
  103. register: swap_result
  104. # Disable Swap Block
  105. - block:
  106. - name: Disable swap
  107. command: swapoff --all
  108. - name: Remove swap entries from /etc/fstab
  109. replace:
  110. dest: /etc/fstab
  111. regexp: '(^[^#].*swap.*)'
  112. replace: '# \1'
  113. backup: yes
  114. - name: Add notice about disabling swap
  115. lineinfile:
  116. dest: /etc/fstab
  117. line: '# OpenShift-Ansible Installer disabled swap per overcommit guidelines'
  118. state: present
  119. when:
  120. - swap_result.stdout_lines | length > 0
  121. - openshift_disable_swap | default(true) | bool
  122. # End Disable Swap Block
  123. - name: Reset selinux context
  124. command: restorecon -RF {{ openshift_node_data_dir }}/openshift.local.volumes
  125. when:
  126. - ansible_selinux is defined
  127. - ansible_selinux.status == 'enabled'
  128. - name: Apply 3.6 dns config changes
  129. yedit:
  130. src: /etc/origin/node/node-config.yaml
  131. key: "{{ item.key }}"
  132. value: "{{ item.value }}"
  133. with_items:
  134. - key: "dnsBindAddress"
  135. value: "127.0.0.1:53"
  136. - key: "dnsRecursiveResolvConf"
  137. value: "/etc/origin/node/resolv.conf"
  138. # Restart all services
  139. - include: restart.yml
  140. - name: Wait for node to be ready
  141. oc_obj:
  142. state: list
  143. kind: node
  144. name: "{{ openshift.common.hostname | lower }}"
  145. register: node_output
  146. delegate_to: "{{ groups.oo_first_master.0 }}"
  147. until: node_output.results.returncode == 0 and node_output.results.results[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  148. # Give the node two minutes to come back online.
  149. retries: 24
  150. delay: 5
  151. - include_role:
  152. name: openshift_node_dnsmasq