config.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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: "{{ openshift.common.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. - deployment_type == 'openshift-enterprise'
  45. with_items:
  46. - master
  47. - node
  48. - .config_managed
  49. - set_fact:
  50. openshift_master_etcd_port: "{{ (etcd_client_port | default('2379')) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else none }}"
  51. openshift_master_etcd_hosts: "{{ hostvars
  52. | oo_select_keys(groups['oo_etcd_to_config']
  53. | default([]))
  54. | oo_collect('openshift.common.hostname')
  55. | default(none, true) }}"
  56. roles:
  57. - openshift_facts
  58. post_tasks:
  59. - openshift_facts:
  60. role: master
  61. local_facts:
  62. api_port: "{{ openshift_master_api_port | default(None) }}"
  63. api_url: "{{ openshift_master_api_url | default(None) }}"
  64. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  65. controllers_port: "{{ openshift_master_controllers_port | default(None) }}"
  66. public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
  67. cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
  68. cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
  69. console_path: "{{ openshift_master_console_path | default(None) }}"
  70. console_port: "{{ openshift_master_console_port | default(None) }}"
  71. console_url: "{{ openshift_master_console_url | default(None) }}"
  72. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  73. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  74. ha: "{{ openshift_master_ha | default(groups.oo_masters | length > 1) }}"
  75. master_count: "{{ openshift_master_count | default(groups.oo_masters | length) }}"
  76. - name: Inspect state of first master config settings
  77. hosts: oo_first_master
  78. roles:
  79. - role: openshift_facts
  80. post_tasks:
  81. - openshift_facts:
  82. role: master
  83. local_facts:
  84. session_auth_secrets: "{{ openshift_master_session_auth_secrets | default(openshift.master.session_auth_secrets | default(None)) }}"
  85. session_encryption_secrets: "{{ openshift_master_session_encryption_secrets | default(openshift.master.session_encryption_secrets | default(None)) }}"
  86. - name: Check for existing configuration
  87. stat:
  88. path: /etc/origin/master/master-config.yaml
  89. register: master_config_stat
  90. - name: Set clean install fact
  91. set_fact:
  92. l_clean_install: "{{ not master_config_stat.stat.exists | bool }}"
  93. - name: Determine if etcd3 storage is in use
  94. command: grep -Pzo "storage-backend:\n.*etcd3" /etc/origin/master/master-config.yaml -q
  95. register: etcd3_grep
  96. failed_when: false
  97. changed_when: false
  98. - name: Set etcd3 fact
  99. set_fact:
  100. l_etcd3_enabled: "{{ etcd3_grep.rc == 0 | bool }}"
  101. - name: Check if atomic-openshift-master sysconfig exists yet
  102. stat:
  103. path: /etc/sysconfig/atomic-openshift-master
  104. register: l_aom_exists
  105. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master parameter if present
  106. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master
  107. register: l_default_registry_defined
  108. when: l_aom_exists.stat.exists | bool
  109. - name: Check if atomic-openshift-master-api sysconfig exists yet
  110. stat:
  111. path: /etc/sysconfig/atomic-openshift-master-api
  112. register: l_aom_api_exists
  113. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-api parameter if present
  114. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-api
  115. register: l_default_registry_defined_api
  116. when: l_aom_api_exists.stat.exists | bool
  117. - name: Check if atomic-openshift-master-controllers sysconfig exists yet
  118. stat:
  119. path: /etc/sysconfig/atomic-openshift-master-controllers
  120. register: l_aom_controllers_exists
  121. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-controllers parameter if present
  122. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-controllers
  123. register: l_default_registry_defined_controllers
  124. when: l_aom_controllers_exists.stat.exists | bool
  125. - name: Update facts with OPENSHIFT_DEFAULT_REGISTRY value
  126. set_fact:
  127. l_default_registry_value: "{{ l_default_registry_defined.stdout | default('') }}"
  128. l_default_registry_value_api: "{{ l_default_registry_defined_api.stdout | default('') }}"
  129. l_default_registry_value_controllers: "{{ l_default_registry_defined_controllers.stdout | default('') }}"
  130. - name: Generate master session secrets
  131. hosts: oo_first_master
  132. vars:
  133. g_session_secrets_present: "{{ (openshift.master.session_auth_secrets | default([])) | length > 0 and (openshift.master.session_encryption_secrets | default([])) | length > 0 }}"
  134. g_session_auth_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  135. g_session_encryption_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  136. roles:
  137. - role: openshift_facts
  138. tasks:
  139. - openshift_facts:
  140. role: master
  141. local_facts:
  142. session_auth_secrets: "{{ g_session_auth_secrets }}"
  143. session_encryption_secrets: "{{ g_session_encryption_secrets }}"
  144. when: not g_session_secrets_present | bool
  145. - name: Configure masters
  146. hosts: oo_masters_to_config
  147. any_errors_fatal: true
  148. vars:
  149. openshift_master_ha: "{{ openshift.master.ha }}"
  150. openshift_master_count: "{{ openshift.master.master_count }}"
  151. openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
  152. openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
  153. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  154. openshift_master_etcd_hosts: "{{ hostvars
  155. | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  156. | oo_collect('openshift.common.hostname')
  157. | default(none, true) }}"
  158. openshift_no_proxy_etcd_host_ips: "{{ hostvars | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  159. | oo_collect('openshift.common.ip') | default([]) | join(',')
  160. }}"
  161. roles:
  162. - role: openshift_master_facts
  163. - role: openshift_hosted_facts
  164. - role: openshift_clock
  165. - role: openshift_cloud_provider
  166. - role: openshift_builddefaults
  167. - role: openshift_buildoverrides
  168. - role: nickhammond.logrotate
  169. - role: contiv
  170. contiv_role: netmaster
  171. when: openshift_use_contiv | default(False) | bool
  172. - role: openshift_master
  173. openshift_master_hosts: "{{ groups.oo_masters_to_config }}"
  174. r_openshift_master_clean_install: "{{ hostvars[groups.oo_first_master.0].l_clean_install }}"
  175. r_openshift_master_etcd3_storage: "{{ hostvars[groups.oo_first_master.0].l_etcd3_enabled }}"
  176. openshift_master_is_scaleup_host: "{{ g_openshift_master_is_scaleup | default(false) }}"
  177. openshift_master_default_registry_value: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value }}"
  178. openshift_master_default_registry_value_api: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value_api }}"
  179. openshift_master_default_registry_value_controllers: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value_controllers }}"
  180. - role: tuned
  181. - role: nuage_ca
  182. when: openshift_use_nuage | default(false) | bool
  183. - role: nuage_common
  184. when: openshift_use_nuage | default(false) | bool
  185. - role: nuage_master
  186. when: openshift_use_nuage | default(false) | bool
  187. - role: calico_master
  188. when: openshift_use_calico | default(false) | bool
  189. tasks:
  190. - include_role:
  191. name: kuryr
  192. tasks_from: master
  193. when: openshift_use_kuryr | default(false) | bool
  194. - name: Setup the node group config maps
  195. include_role:
  196. name: openshift_node_group
  197. when: openshift_master_bootstrap_enabled | default(false) | bool
  198. run_once: True
  199. post_tasks:
  200. - name: Create group for deployment type
  201. group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }}
  202. changed_when: False
  203. - name: Configure API Aggregation on masters
  204. hosts: oo_masters
  205. serial: 1
  206. roles:
  207. - role: openshift_facts
  208. tasks:
  209. - include_tasks: tasks/wire_aggregator.yml
  210. - name: Re-enable excluder if it was previously enabled
  211. hosts: oo_masters_to_config
  212. gather_facts: no
  213. roles:
  214. - role: openshift_excluder
  215. r_openshift_excluder_action: enable
  216. - name: Master Install Checkpoint End
  217. hosts: all
  218. gather_facts: false
  219. tasks:
  220. - name: Set Master install 'Complete'
  221. run_once: true
  222. set_stats:
  223. data:
  224. installer_phase_master:
  225. status: "Complete"
  226. end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}"