config.yml 11 KB

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