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. r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
  21. - name: Gather and set facts for master hosts
  22. hosts: oo_masters_to_config
  23. pre_tasks:
  24. # Per https://bugzilla.redhat.com/show_bug.cgi?id=1469336
  25. #
  26. # When scaling up a cluster upgraded from OCP <= 3.5, ensure that
  27. # OPENSHIFT_DEFAULT_REGISTRY is present as defined on the existing
  28. # masters, or absent if such is the case.
  29. - name: Detect if this host is a new master in a scale up
  30. set_fact:
  31. g_openshift_master_is_scaleup: "{{ openshift.common.hostname in ( groups['new_masters'] | default([]) ) }}"
  32. - name: Scaleup Detection
  33. debug:
  34. var: g_openshift_master_is_scaleup
  35. - name: Check for RPM generated config marker file .config_managed
  36. stat:
  37. path: /etc/origin/.config_managed
  38. register: rpmgenerated_config
  39. - name: Remove RPM generated config files if present
  40. file:
  41. path: "/etc/origin/{{ item }}"
  42. state: absent
  43. when:
  44. - rpmgenerated_config.stat.exists == true
  45. - deployment_type == 'openshift-enterprise'
  46. with_items:
  47. - master
  48. - node
  49. - .config_managed
  50. - set_fact:
  51. 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 }}"
  52. openshift_master_etcd_hosts: "{{ hostvars
  53. | oo_select_keys(groups['oo_etcd_to_config']
  54. | default([]))
  55. | oo_collect('openshift.common.hostname')
  56. | default(none, true) }}"
  57. roles:
  58. - openshift_facts
  59. post_tasks:
  60. - openshift_facts:
  61. role: master
  62. local_facts:
  63. api_port: "{{ openshift_master_api_port | default(None) }}"
  64. api_url: "{{ openshift_master_api_url | default(None) }}"
  65. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  66. controllers_port: "{{ openshift_master_controllers_port | default(None) }}"
  67. public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
  68. cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
  69. cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
  70. console_path: "{{ openshift_master_console_path | default(None) }}"
  71. console_port: "{{ openshift_master_console_port | default(None) }}"
  72. console_url: "{{ openshift_master_console_url | default(None) }}"
  73. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  74. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  75. ha: "{{ openshift_master_ha | default(groups.oo_masters | length > 1) }}"
  76. master_count: "{{ openshift_master_count | default(groups.oo_masters | length) }}"
  77. - name: Inspect state of first master config settings
  78. hosts: oo_first_master
  79. roles:
  80. - role: openshift_facts
  81. post_tasks:
  82. - openshift_facts:
  83. role: master
  84. local_facts:
  85. session_auth_secrets: "{{ openshift_master_session_auth_secrets | default(openshift.master.session_auth_secrets | default(None)) }}"
  86. session_encryption_secrets: "{{ openshift_master_session_encryption_secrets | default(openshift.master.session_encryption_secrets | default(None)) }}"
  87. - name: Check for existing configuration
  88. stat:
  89. path: /etc/origin/master/master-config.yaml
  90. register: master_config_stat
  91. - name: Set clean install fact
  92. set_fact:
  93. l_clean_install: "{{ not master_config_stat.stat.exists | bool }}"
  94. - name: Determine if etcd3 storage is in use
  95. command: grep -Pzo "storage-backend:\n.*etcd3" /etc/origin/master/master-config.yaml -q
  96. register: etcd3_grep
  97. failed_when: false
  98. changed_when: false
  99. - name: Set etcd3 fact
  100. set_fact:
  101. l_etcd3_enabled: "{{ etcd3_grep.rc == 0 | bool }}"
  102. - name: Check if atomic-openshift-master sysconfig exists yet
  103. stat:
  104. path: /etc/sysconfig/atomic-openshift-master
  105. register: l_aom_exists
  106. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master parameter if present
  107. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master
  108. register: l_default_registry_defined
  109. when: l_aom_exists.stat.exists | bool
  110. - name: Check if atomic-openshift-master-api sysconfig exists yet
  111. stat:
  112. path: /etc/sysconfig/atomic-openshift-master-api
  113. register: l_aom_api_exists
  114. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-api parameter if present
  115. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-api
  116. register: l_default_registry_defined_api
  117. when: l_aom_api_exists.stat.exists | bool
  118. - name: Check if atomic-openshift-master-controllers sysconfig exists yet
  119. stat:
  120. path: /etc/sysconfig/atomic-openshift-master-controllers
  121. register: l_aom_controllers_exists
  122. - name: Preserve OPENSHIFT_DEFAULT_REGISTRY master-controllers parameter if present
  123. command: awk '/^OPENSHIFT_DEFAULT_REGISTRY/' /etc/sysconfig/atomic-openshift-master-controllers
  124. register: l_default_registry_defined_controllers
  125. when: l_aom_controllers_exists.stat.exists | bool
  126. - name: Update facts with OPENSHIFT_DEFAULT_REGISTRY value
  127. set_fact:
  128. l_default_registry_value: "{{ l_default_registry_defined.stdout | default('') }}"
  129. l_default_registry_value_api: "{{ l_default_registry_defined_api.stdout | default('') }}"
  130. l_default_registry_value_controllers: "{{ l_default_registry_defined_controllers.stdout | default('') }}"
  131. - name: Generate master session secrets
  132. hosts: oo_first_master
  133. vars:
  134. g_session_secrets_present: "{{ (openshift.master.session_auth_secrets | default([])) | length > 0 and (openshift.master.session_encryption_secrets | default([])) | length > 0 }}"
  135. g_session_auth_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  136. g_session_encryption_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  137. roles:
  138. - role: openshift_facts
  139. tasks:
  140. - openshift_facts:
  141. role: master
  142. local_facts:
  143. session_auth_secrets: "{{ g_session_auth_secrets }}"
  144. session_encryption_secrets: "{{ g_session_encryption_secrets }}"
  145. when: not g_session_secrets_present | bool
  146. - name: Configure masters
  147. hosts: oo_masters_to_config
  148. any_errors_fatal: true
  149. vars:
  150. openshift_master_ha: "{{ openshift.master.ha }}"
  151. openshift_master_count: "{{ openshift.master.master_count }}"
  152. openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
  153. openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
  154. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  155. openshift_master_etcd_hosts: "{{ hostvars
  156. | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  157. | oo_collect('openshift.common.hostname')
  158. | default(none, true) }}"
  159. openshift_no_proxy_etcd_host_ips: "{{ hostvars | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  160. | oo_collect('openshift.common.ip') | default([]) | join(',')
  161. }}"
  162. roles:
  163. - role: openshift_master_facts
  164. - role: openshift_hosted_facts
  165. - role: openshift_clock
  166. - role: openshift_cloud_provider
  167. - role: openshift_builddefaults
  168. - role: openshift_buildoverrides
  169. - role: nickhammond.logrotate
  170. - role: contiv
  171. contiv_role: netmaster
  172. when: openshift_use_contiv | default(False) | bool
  173. - role: openshift_master
  174. openshift_master_hosts: "{{ groups.oo_masters_to_config }}"
  175. r_openshift_master_clean_install: "{{ hostvars[groups.oo_first_master.0].l_clean_install }}"
  176. r_openshift_master_etcd3_storage: "{{ hostvars[groups.oo_first_master.0].l_etcd3_enabled }}"
  177. openshift_master_is_scaleup_host: "{{ g_openshift_master_is_scaleup | default(false) }}"
  178. openshift_master_default_registry_value: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value }}"
  179. openshift_master_default_registry_value_api: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value_api }}"
  180. openshift_master_default_registry_value_controllers: "{{ hostvars[groups.oo_first_master.0].l_default_registry_value_controllers }}"
  181. - role: tuned
  182. - role: nuage_ca
  183. when: openshift_use_nuage | default(false) | bool
  184. - role: nuage_common
  185. when: openshift_use_nuage | default(false) | bool
  186. - role: nuage_master
  187. when: openshift_use_nuage | default(false) | bool
  188. - role: calico_master
  189. when: openshift_use_calico | default(false) | bool
  190. tasks:
  191. - include_role:
  192. name: kuryr
  193. tasks_from: master
  194. when: openshift_use_kuryr | default(false) | bool
  195. - name: Setup the node group config maps
  196. include_role:
  197. name: openshift_node_group
  198. when: openshift_master_bootstrap_enabled | default(false) | bool
  199. run_once: True
  200. post_tasks:
  201. - name: Create group for deployment type
  202. group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }}
  203. changed_when: False
  204. - name: Configure API Aggregation on masters
  205. hosts: oo_masters
  206. serial: 1
  207. tasks:
  208. - include_tasks: tasks/wire_aggregator.yml
  209. - name: Re-enable excluder if it was previously enabled
  210. hosts: oo_masters_to_config
  211. gather_facts: no
  212. roles:
  213. - role: openshift_excluder
  214. r_openshift_excluder_action: enable
  215. r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
  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') }}"