upgrade_control_plane.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ---
  2. ###############################################################################
  3. # Upgrade Masters
  4. ###############################################################################
  5. - name: Evaluate additional groups for upgrade
  6. hosts: localhost
  7. connection: local
  8. become: no
  9. tasks:
  10. - name: Evaluate etcd_hosts_to_backup
  11. add_host:
  12. name: "{{ item }}"
  13. groups: etcd_hosts_to_backup
  14. with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else groups.oo_first_master }}"
  15. # If facts cache were for some reason deleted, this fact may not be set, and if not set
  16. # it will always default to true. This causes problems for the etcd data dir fact detection
  17. # so we must first make sure this is set correctly before attempting the backup.
  18. - name: Set master embedded_etcd fact
  19. hosts: oo_masters_to_config
  20. roles:
  21. - openshift_facts
  22. tasks:
  23. - openshift_facts:
  24. role: master
  25. local_facts:
  26. embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}"
  27. debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level | default(2)) }}"
  28. - name: Upgrade and backup etcd
  29. include: ./etcd/main.yml
  30. # Create service signer cert when missing. Service signer certificate
  31. # is added to master config in the master config hook for v3_3.
  32. - name: Determine if service signer cert must be created
  33. hosts: oo_first_master
  34. tasks:
  35. - name: Determine if service signer certificate must be created
  36. stat:
  37. path: "{{ openshift.common.config_base }}/master/service-signer.crt"
  38. register: service_signer_cert_stat
  39. changed_when: false
  40. - include: create_service_signer_cert.yml
  41. # Set openshift_master_facts separately. In order to reconcile
  42. # admission_config's, we currently must run openshift_master_facts and
  43. # then run openshift_facts.
  44. - name: Set OpenShift master facts
  45. hosts: oo_masters_to_config
  46. roles:
  47. - openshift_master_facts
  48. - name: Upgrade master
  49. hosts: oo_masters_to_config
  50. vars:
  51. openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}"
  52. serial: 1
  53. handlers:
  54. - include: ../../../../roles/openshift_master/handlers/main.yml
  55. static: yes
  56. roles:
  57. - openshift_facts
  58. post_tasks:
  59. - include: rpm_upgrade.yml component=master
  60. when: not openshift.common.is_containerized | bool
  61. - include_vars: ../../../../roles/openshift_master_facts/vars/main.yml
  62. - include: upgrade_scheduler.yml
  63. - include: "{{ master_config_hook }}"
  64. when: master_config_hook is defined
  65. - include_vars: ../../../../roles/openshift_master/vars/main.yml
  66. - name: Update systemd units
  67. include: ../../../../roles/openshift_master/tasks/systemd_units.yml
  68. - name: Check for ca-bundle.crt
  69. stat:
  70. path: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
  71. register: ca_bundle_stat
  72. failed_when: false
  73. - name: Check for ca.crt
  74. stat:
  75. path: "{{ openshift.common.config_base }}/master/ca.crt"
  76. register: ca_crt_stat
  77. failed_when: false
  78. - name: Migrate ca.crt to ca-bundle.crt
  79. command: mv ca.crt ca-bundle.crt
  80. args:
  81. chdir: "{{ openshift.common.config_base }}/master"
  82. when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists
  83. - name: Link ca.crt to ca-bundle.crt
  84. file:
  85. src: "{{ openshift.common.config_base }}/master/ca-bundle.crt"
  86. path: "{{ openshift.common.config_base }}/master/ca.crt"
  87. state: link
  88. when: ca_crt_stat.stat.isreg and not ca_bundle_stat.stat.exists
  89. - include: ../../openshift-master/restart_hosts.yml
  90. when: openshift.common.rolling_restart_mode == 'system'
  91. - include: ../../openshift-master/restart_services.yml
  92. when: openshift.common.rolling_restart_mode == 'services'
  93. - set_fact:
  94. master_update_complete: True
  95. ##############################################################################
  96. # Gate on master update complete
  97. ##############################################################################
  98. - name: Gate on master update
  99. hosts: localhost
  100. connection: local
  101. become: no
  102. tasks:
  103. - set_fact:
  104. master_update_completed: "{{ hostvars
  105. | oo_select_keys(groups.oo_masters_to_config)
  106. | oo_collect('inventory_hostname', {'master_update_complete': true}) }}"
  107. - set_fact:
  108. master_update_failed: "{{ groups.oo_masters_to_config | difference(master_update_completed) }}"
  109. - fail:
  110. msg: "Upgrade cannot continue. The following masters did not finish updating: {{ master_update_failed | join(',') }}"
  111. when: master_update_failed | length > 0
  112. ###############################################################################
  113. # Reconcile Cluster Roles, Cluster Role Bindings and Security Context Constraints
  114. ###############################################################################
  115. - name: Reconcile Cluster Roles and Cluster Role Bindings and Security Context Constraints
  116. hosts: oo_masters_to_config
  117. roles:
  118. - { role: openshift_cli }
  119. vars:
  120. origin_reconcile_bindings: "{{ deployment_type == 'origin' and openshift_version | version_compare('1.0.6', '>') }}"
  121. ent_reconcile_bindings: true
  122. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  123. # Another spot where we assume docker is running and do not want to accidentally trigger an unsafe
  124. # restart.
  125. skip_docker_role: True
  126. tasks:
  127. - name: Reconcile Cluster Roles
  128. command: >
  129. {{ openshift.common.client_binary }} adm --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  130. policy reconcile-cluster-roles --additive-only=true --confirm
  131. run_once: true
  132. - name: Reconcile Cluster Role Bindings
  133. command: >
  134. {{ openshift.common.client_binary }} adm --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  135. policy reconcile-cluster-role-bindings
  136. --exclude-groups=system:authenticated
  137. --exclude-groups=system:authenticated:oauth
  138. --exclude-groups=system:unauthenticated
  139. --exclude-users=system:anonymous
  140. --additive-only=true --confirm
  141. when: origin_reconcile_bindings | bool or ent_reconcile_bindings | bool
  142. run_once: true
  143. - name: Reconcile Jenkins Pipeline Role Bindings
  144. command: >
  145. {{ openshift.common.client_binary }} adm --config={{ openshift.common.config_base }}/master/admin.kubeconfig policy reconcile-cluster-role-bindings system:build-strategy-jenkinspipeline --confirm
  146. run_once: true
  147. when: openshift.common.version_gte_3_4_or_1_4 | bool
  148. - name: Reconcile Security Context Constraints
  149. command: >
  150. {{ openshift.common.client_binary }} adm policy reconcile-sccs --confirm --additive-only=true
  151. run_once: true
  152. - set_fact:
  153. reconcile_complete: True
  154. ##############################################################################
  155. # Gate on reconcile
  156. ##############################################################################
  157. - name: Gate on reconcile
  158. hosts: localhost
  159. connection: local
  160. become: no
  161. tasks:
  162. - set_fact:
  163. reconcile_completed: "{{ hostvars
  164. | oo_select_keys(groups.oo_masters_to_config)
  165. | oo_collect('inventory_hostname', {'reconcile_complete': true}) }}"
  166. - set_fact:
  167. reconcile_failed: "{{ groups.oo_masters_to_config | difference(reconcile_completed) }}"
  168. - fail:
  169. msg: "Upgrade cannot continue. The following masters did not finish reconciling: {{ reconcile_failed | join(',') }}"
  170. when: reconcile_failed | length > 0
  171. - name: Upgrade Docker on dedicated containerized etcd hosts
  172. hosts: oo_etcd_to_config:!oo_nodes_to_upgrade
  173. serial: 1
  174. any_errors_fatal: true
  175. roles:
  176. - openshift_facts
  177. tasks:
  178. - include: docker/upgrade.yml
  179. when: l_docker_upgrade is defined and l_docker_upgrade | bool and not openshift.common.is_atomic | bool