main.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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"
  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. - include: docker/upgrade.yml
  31. vars:
  32. # We will restart Docker ourselves after everything is ready:
  33. skip_docker_restart: True
  34. when:
  35. - l_docker_upgrade is defined
  36. - l_docker_upgrade | bool
  37. - include: "{{ node_config_hook }}"
  38. when: node_config_hook is defined
  39. - include: rpm_upgrade.yml
  40. vars:
  41. component: "node"
  42. openshift_version: "{{ openshift_pkg_version | default('') }}"
  43. when: not openshift.common.is_containerized | bool
  44. - name: Remove obsolete docker-sdn-ovs.conf
  45. file:
  46. path: "/etc/systemd/system/docker.service.d/docker-sdn-ovs.conf"
  47. state: absent
  48. when: (deployment_type == 'openshift-enterprise' and openshift_release | version_compare('3.4', '>='))
  49. or (deployment_type == 'origin' and openshift_release | version_compare('1.4', '>='))
  50. - include: containerized_node_upgrade.yml
  51. when: openshift.common.is_containerized | bool
  52. - name: Ensure containerized services stopped before Docker restart
  53. service:
  54. name: "{{ item }}"
  55. state: stopped
  56. with_items:
  57. - etcd_container
  58. - openvswitch
  59. - "{{ openshift.common.service_type }}-master"
  60. - "{{ openshift.common.service_type }}-master-api"
  61. - "{{ openshift.common.service_type }}-master-controllers"
  62. - "{{ openshift.common.service_type }}-node"
  63. failed_when: false
  64. when: openshift.common.is_containerized | bool
  65. - name: Stop rpm based services
  66. service:
  67. name: "{{ item }}"
  68. state: stopped
  69. with_items:
  70. - "{{ openshift.common.service_type }}-node"
  71. - openvswitch
  72. failed_when: false
  73. when: not openshift.common.is_containerized | bool
  74. - name: Upgrade openvswitch
  75. package:
  76. name: openvswitch
  77. state: latest
  78. when: not openshift.common.is_containerized | bool
  79. - name: Update oreg value
  80. yedit:
  81. src: "{{ openshift.common.config_base }}/node/node-config.yaml"
  82. key: 'imageConfig.format'
  83. value: "{{ oreg_url }}"
  84. when: oreg_url is defined
  85. # https://docs.openshift.com/container-platform/3.4/admin_guide/overcommit.html#disabling-swap-memory
  86. - name: Check for swap usage
  87. command: grep "^[^#].*swap" /etc/fstab
  88. # grep: match any lines which don't begin with '#' and contain 'swap'
  89. changed_when: false
  90. failed_when: false
  91. register: swap_result
  92. # Disable Swap Block
  93. - block:
  94. - name: Disable swap
  95. command: swapoff --all
  96. - name: Remove swap entries from /etc/fstab
  97. replace:
  98. dest: /etc/fstab
  99. regexp: '(^[^#].*swap.*)'
  100. replace: '# \1'
  101. backup: yes
  102. - name: Add notice about disabling swap
  103. lineinfile:
  104. dest: /etc/fstab
  105. line: '# OpenShift-Ansible Installer disabled swap per overcommit guidelines'
  106. state: present
  107. when:
  108. - swap_result.stdout_lines | length > 0
  109. - openshift_disable_swap | default(true) | bool
  110. # End Disable Swap Block
  111. # Restart all services
  112. - include: restart.yml
  113. - name: Wait for node to be ready
  114. oc_obj:
  115. state: list
  116. kind: node
  117. name: "{{ openshift.common.hostname | lower }}"
  118. register: node_output
  119. delegate_to: "{{ groups.oo_first_master.0 }}"
  120. until: node_output.results.results[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  121. # Give the node two minutes to come back online.
  122. retries: 24
  123. delay: 5