upgrade_control_plane.yml 7.8 KB

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