config.yml 11 KB

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