upgrade.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. ---
  2. ###############################################################################
  3. # The restart playbook should be run after this playbook completes.
  4. ###############################################################################
  5. - name: Upgrade docker
  6. hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config
  7. roles:
  8. - openshift_facts
  9. tasks:
  10. - include: docker_upgrade.yml
  11. when: not openshift.common.is_atomic | bool
  12. - name: Set post docker install facts
  13. openshift_facts:
  14. role: "{{ item.role }}"
  15. local_facts: "{{ item.local_facts }}"
  16. with_items:
  17. - role: docker
  18. local_facts:
  19. openshift_image_tag: "v{{ g_new_version }}"
  20. openshift_version: "{{ g_new_version }}"
  21. # The cli image is used by openshift_docker_facts to determine the currently installed
  22. # version. We need to explicitly pull the latest image to handle cases where
  23. # the locally cached 'latest' tag is older the g_new_version.
  24. - name: Download cli image
  25. hosts: oo_masters_to_config:oo_nodes_to_config
  26. roles:
  27. - { role: openshift_docker_facts }
  28. vars:
  29. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  30. tasks:
  31. - name: Pull Images
  32. command: >
  33. docker pull {{ item }}:latest
  34. with_items:
  35. - "{{ openshift.common.cli_image }}"
  36. when: openshift.common.is_containerized | bool
  37. ###############################################################################
  38. # Upgrade Masters
  39. ###############################################################################
  40. - name: Upgrade master
  41. hosts: oo_masters_to_config
  42. handlers:
  43. - include: ../../../../../roles/openshift_master/handlers/main.yml
  44. roles:
  45. - openshift_facts
  46. tasks:
  47. - include: rpm_upgrade.yml component=master
  48. when: not openshift.common.is_containerized | bool
  49. - include_vars: ../../../../../roles/openshift_master/vars/main.yml
  50. - name: Update systemd units
  51. include: ../../../../../roles/openshift_master/tasks/systemd_units.yml openshift_version=v{{ g_new_version }}
  52. # - name: Upgrade master configuration
  53. # openshift_upgrade_config:
  54. # from_version: '3.1'
  55. # to_version: '3.2'
  56. # role: master
  57. # config_base: "{{ hostvars[inventory_hostname].openshift.common.config_base }}"
  58. - name: Set master update status to complete
  59. hosts: oo_masters_to_config
  60. tasks:
  61. - set_fact:
  62. master_update_complete: True
  63. ##############################################################################
  64. # Gate on master update complete
  65. ##############################################################################
  66. - name: Gate on master update
  67. hosts: localhost
  68. connection: local
  69. become: no
  70. tasks:
  71. - set_fact:
  72. master_update_completed: "{{ hostvars
  73. | oo_select_keys(groups.oo_masters_to_config)
  74. | oo_collect('inventory_hostname', {'master_update_complete': true}) }}"
  75. - set_fact:
  76. master_update_failed: "{{ groups.oo_masters_to_config | difference(master_update_completed) }}"
  77. - fail:
  78. msg: "Upgrade cannot continue. The following masters did not finish updating: {{ master_update_failed | join(',') }}"
  79. when: master_update_failed | length > 0
  80. ###############################################################################
  81. # Upgrade Nodes
  82. ###############################################################################
  83. - name: Upgrade nodes
  84. hosts: oo_nodes_to_config
  85. serial: 1
  86. roles:
  87. - openshift_facts
  88. handlers:
  89. - include: ../../../../../roles/openshift_node/handlers/main.yml
  90. tasks:
  91. - include: node_upgrade.yml
  92. - set_fact:
  93. node_update_complete: True
  94. ##############################################################################
  95. # Gate on nodes update
  96. ##############################################################################
  97. - name: Gate on nodes update
  98. hosts: localhost
  99. connection: local
  100. become: no
  101. tasks:
  102. - set_fact:
  103. node_update_completed: "{{ hostvars
  104. | oo_select_keys(groups.oo_nodes_to_config)
  105. | oo_collect('inventory_hostname', {'node_update_complete': true}) }}"
  106. - set_fact:
  107. node_update_failed: "{{ groups.oo_nodes_to_config | difference(node_update_completed) }}"
  108. - fail:
  109. msg: "Upgrade cannot continue. The following nodes did not finish updating: {{ node_update_failed | join(',') }}"
  110. when: node_update_failed | length > 0
  111. ###############################################################################
  112. # Reconcile Cluster Roles, Cluster Role Bindings and Security Context Constraints
  113. ###############################################################################
  114. - name: Reconcile Cluster Roles and Cluster Role Bindings and Security Context Constraints
  115. hosts: oo_masters_to_config
  116. roles:
  117. - { role: openshift_cli, openshift_image_tag: "v{{ g_new_version }}" }
  118. vars:
  119. origin_reconcile_bindings: "{{ deployment_type == 'origin' and g_new_version | version_compare('1.0.6', '>') }}"
  120. ent_reconcile_bindings: true
  121. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  122. tasks:
  123. - name: Verifying the correct commandline tools are available
  124. shell: grep {{ verify_upgrade_version }} {{ openshift.common.admin_binary}}
  125. when: openshift.common.is_containerized | bool and verify_upgrade_version is defined
  126. - name: Reconcile Cluster Roles
  127. command: >
  128. {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  129. policy reconcile-cluster-roles --additive-only=true --confirm
  130. run_once: true
  131. - name: Reconcile Cluster Role Bindings
  132. command: >
  133. {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  134. policy reconcile-cluster-role-bindings
  135. --exclude-groups=system:authenticated
  136. --exclude-groups=system:authenticated:oauth
  137. --exclude-groups=system:unauthenticated
  138. --exclude-users=system:anonymous
  139. --additive-only=true --confirm
  140. when: origin_reconcile_bindings | bool or ent_reconcile_bindings | bool
  141. run_once: true
  142. - name: Reconcile Security Context Constraints
  143. command: >
  144. {{ openshift.common.admin_binary}} policy reconcile-sccs --confirm --additive-only=true
  145. run_once: true
  146. - set_fact:
  147. reconcile_complete: True
  148. ##############################################################################
  149. # Gate on reconcile
  150. ##############################################################################
  151. - name: Gate on reconcile
  152. hosts: localhost
  153. connection: local
  154. become: no
  155. tasks:
  156. - set_fact:
  157. reconcile_completed: "{{ hostvars
  158. | oo_select_keys(groups.oo_masters_to_config)
  159. | oo_collect('inventory_hostname', {'reconcile_complete': true}) }}"
  160. - set_fact:
  161. reconcile_failed: "{{ groups.oo_masters_to_config | difference(reconcile_completed) }}"
  162. - fail:
  163. msg: "Upgrade cannot continue. The following masters did not finish reconciling: {{ reconcile_failed | join(',') }}"
  164. when: reconcile_failed | length > 0