upgrade_control_plane.yml 7.5 KB

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