upgrade.yml 5.0 KB

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