config.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. ---
  2. - name: Master Install Checkpoint Start
  3. hosts: all
  4. gather_facts: false
  5. tasks:
  6. - name: Set Master install 'In Progress'
  7. run_once: true
  8. set_stats:
  9. data:
  10. installer_phase_master:
  11. status: "In Progress"
  12. start: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"
  13. - import_playbook: certificates.yml
  14. - name: Disable excluders
  15. hosts: oo_masters_to_config
  16. gather_facts: no
  17. roles:
  18. - role: openshift_excluder
  19. r_openshift_excluder_action: disable
  20. - name: Gather and set facts for master hosts
  21. hosts: oo_masters_to_config
  22. pre_tasks:
  23. # Per https://bugzilla.redhat.com/show_bug.cgi?id=1469336
  24. #
  25. # When scaling up a cluster upgraded from OCP <= 3.5, ensure that
  26. # OPENSHIFT_DEFAULT_REGISTRY is present as defined on the existing
  27. # masters, or absent if such is the case.
  28. - name: Detect if this host is a new master in a scale up
  29. set_fact:
  30. g_openshift_master_is_scaleup: "{{ inventory_hostname in ( groups['new_masters'] | default([]) ) }}"
  31. - name: Scaleup Detection
  32. debug:
  33. var: g_openshift_master_is_scaleup
  34. - name: Check for RPM generated config marker file .config_managed
  35. stat:
  36. path: /etc/origin/.config_managed
  37. register: rpmgenerated_config
  38. - name: Remove RPM generated config files if present
  39. file:
  40. path: "/etc/origin/{{ item }}"
  41. state: absent
  42. when:
  43. - rpmgenerated_config.stat.exists == true
  44. - openshift_deployment_type == 'openshift-enterprise'
  45. with_items:
  46. - master
  47. - node
  48. - .config_managed
  49. roles:
  50. - openshift_facts
  51. post_tasks:
  52. - openshift_facts:
  53. role: master
  54. local_facts:
  55. api_port: "{{ openshift_master_api_port | default(None) }}"
  56. api_url: "{{ openshift_master_api_url | default(None) }}"
  57. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  58. controllers_port: "{{ openshift_master_controllers_port | default(None) }}"
  59. public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
  60. cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
  61. cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
  62. console_path: "{{ openshift_master_console_path | default(None) }}"
  63. console_port: "{{ openshift_master_console_port | default(None) }}"
  64. console_url: "{{ openshift_master_console_url | default(None) }}"
  65. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  66. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  67. master_count: "{{ openshift_master_count | default(groups.oo_masters | length) }}"
  68. - name: Inspect state of first master config settings
  69. hosts: oo_first_master
  70. roles:
  71. - role: openshift_facts
  72. post_tasks:
  73. - openshift_facts:
  74. role: master
  75. local_facts:
  76. session_auth_secrets: "{{ openshift_master_session_auth_secrets | default(openshift.master.session_auth_secrets | default(None)) }}"
  77. session_encryption_secrets: "{{ openshift_master_session_encryption_secrets | default(openshift.master.session_encryption_secrets | default(None)) }}"
  78. - name: Check for existing configuration
  79. stat:
  80. path: /etc/origin/master/master-config.yaml
  81. register: master_config_stat
  82. - name: Set clean install fact
  83. set_fact:
  84. l_clean_install: "{{ not master_config_stat.stat.exists | bool }}"
  85. - name: Determine if etcd3 storage is in use
  86. command: grep -Pzo "storage-backend:\n.*etcd3" /etc/origin/master/master-config.yaml -q
  87. register: etcd3_grep
  88. failed_when: false
  89. changed_when: false
  90. - name: Set etcd3 fact
  91. set_fact:
  92. l_etcd3_enabled: "{{ etcd3_grep.rc == 0 | bool }}"
  93. - name: Check if atomic-openshift-master sysconfig exists yet
  94. stat:
  95. path: /etc/sysconfig/atomic-openshift-master
  96. register: l_aom_exists
  97. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master parameter if present
  98. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master
  99. register: l_default_registry_defined
  100. when: l_aom_exists.stat.exists | bool
  101. - name: Check if atomic-openshift-master-api sysconfig exists yet
  102. stat:
  103. path: /etc/sysconfig/atomic-openshift-master-api
  104. register: l_aom_api_exists
  105. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-api parameter if present
  106. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-api
  107. register: l_default_registry_defined_api
  108. when: l_aom_api_exists.stat.exists | bool
  109. - name: Check if atomic-openshift-master-controllers sysconfig exists yet
  110. stat:
  111. path: /etc/sysconfig/atomic-openshift-master-controllers
  112. register: l_aom_controllers_exists
  113. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-controllers parameter if present
  114. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-controllers
  115. register: l_default_registry_defined_controllers
  116. when: l_aom_controllers_exists.stat.exists | bool
  117. - name: Update facts with OPENSHIFT_DEFAULT_REGISTRY value
  118. set_fact:
  119. l_default_registry_value: "{{ l_default_registry_defined.stdout | default('') }}"
  120. l_default_registry_value_api: "{{ l_default_registry_defined_api.stdout | default('') }}"
  121. l_default_registry_value_controllers: "{{ l_default_registry_defined_controllers.stdout | default('') }}"
  122. - name: Generate master session secrets
  123. hosts: oo_first_master
  124. vars:
  125. g_session_secrets_present: "{{ (openshift.master.session_auth_secrets | default([])) | length > 0 and (openshift.master.session_encryption_secrets | default([])) | length > 0 }}"
  126. g_session_auth_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
  127. g_session_encryption_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
  128. roles:
  129. - role: openshift_facts
  130. tasks:
  131. - openshift_facts:
  132. role: master
  133. local_facts:
  134. session_auth_secrets: "{{ g_session_auth_secrets }}"
  135. session_encryption_secrets: "{{ g_session_encryption_secrets }}"
  136. when: not g_session_secrets_present | bool
  137. - name: Configure masters
  138. hosts: oo_masters_to_config
  139. any_errors_fatal: true
  140. vars:
  141. openshift_master_count: "{{ openshift.master.master_count }}"
  142. openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
  143. openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
  144. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  145. pre_tasks:
  146. - name: Prepare the bootstrap node config on masters for self-hosting
  147. import_role:
  148. name: openshift_node_group
  149. tasks_from: bootstrap
  150. # TODO: move me into a more appropriate location
  151. - name: Update the sysconfig for the masters to give them bootstrap config
  152. lineinfile:
  153. dest: "/etc/sysconfig/{{ openshift_service_type }}-node"
  154. line: "{{ item.line | default(omit) }}"
  155. regexp: "{{ item.regexp }}"
  156. state: "{{ item.state | default('present') }}"
  157. with_items:
  158. - line: "BOOTSTRAP_CONFIG_NAME={{ openshift_node_group_master | default('node-config-master') }}"
  159. regexp: "^BOOTSTRAP_CONFIG_NAME=.*"
  160. roles:
  161. - role: openshift_master_facts
  162. - role: openshift_clock
  163. - role: openshift_cloud_provider
  164. when: openshift_cloudprovider_kind is defined
  165. - role: openshift_builddefaults
  166. - role: openshift_buildoverrides
  167. - role: nickhammond.logrotate
  168. - role: openshift_control_plane
  169. - role: tuned
  170. - role: nuage_ca
  171. when: openshift_use_nuage | default(false) | bool
  172. - role: nuage_common
  173. when: openshift_use_nuage | default(false) | bool
  174. - role: nuage_master
  175. when: openshift_use_nuage | default(false) | bool
  176. - role: calico_master
  177. when: openshift_use_calico | default(false) | bool
  178. tasks:
  179. - name: Set up automatic node config reconcilation
  180. import_role:
  181. name: openshift_node_group
  182. tasks_from: sync
  183. - import_role:
  184. name: kuryr
  185. tasks_from: master
  186. when: openshift_use_kuryr | default(false) | bool
  187. - name: setup bootstrap settings
  188. include_tasks: tasks/enable_bootstrap.yml
  189. post_tasks:
  190. - name: Create group for deployment type
  191. group_by: key=oo_masters_deployment_type_{{ openshift_deployment_type }}
  192. changed_when: False
  193. - name: Re-enable excluder if it was previously enabled
  194. hosts: oo_masters_to_config
  195. gather_facts: no
  196. roles:
  197. - role: openshift_excluder
  198. r_openshift_excluder_action: enable
  199. - name: Master Install Checkpoint End
  200. hosts: all
  201. gather_facts: false
  202. tasks:
  203. - name: Set Master install 'Complete'
  204. run_once: true
  205. set_stats:
  206. data:
  207. installer_phase_master:
  208. status: "Complete"
  209. end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"