config.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. ---
  2. - name: Set master facts and determine if external etcd certs need to be generated
  3. hosts: oo_masters_to_config
  4. vars:
  5. t_oo_option_master_debug_level: "{{ lookup('oo_option', 'openshift_master_debug_level') }}"
  6. pre_tasks:
  7. - name: Check for RPM generated config marker file .config_managed
  8. stat:
  9. path: /etc/origin/.config_managed
  10. register: rpmgenerated_config
  11. - name: Remove RPM generated config files if present
  12. file:
  13. path: "/etc/origin/{{ item }}"
  14. state: absent
  15. when: rpmgenerated_config.stat.exists == true and deployment_type in ['openshift-enterprise', 'atomic-enterprise']
  16. with_items:
  17. - master
  18. - node
  19. - .config_managed
  20. - set_fact:
  21. openshift_master_pod_eviction_timeout: "{{ lookup('oo_option', 'openshift_master_pod_eviction_timeout') | default(none, true) }}"
  22. when: openshift_master_pod_eviction_timeout is not defined
  23. - set_fact:
  24. 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 }}"
  25. openshift_master_etcd_hosts: "{{ hostvars
  26. | oo_select_keys(groups['oo_etcd_to_config']
  27. | default([]))
  28. | oo_collect('openshift.common.hostname')
  29. | default(none, true) }}"
  30. - set_fact:
  31. openshift_master_debug_level: "{{ t_oo_option_master_debug_level }}"
  32. when: openshift_master_debug_level is not defined and t_oo_option_master_debug_level != ""
  33. - set_fact:
  34. openshift_master_default_subdomain: "{{ lookup('oo_option', 'openshift_master_default_subdomain') | default(None, true) }}"
  35. when: openshift_master_default_subdomain is not defined
  36. - set_fact:
  37. openshift_hosted_metrics_deploy: "{{ lookup('oo_option', 'openshift_hosted_metrics_deploy') | default(false, true) }}"
  38. when: openshift_hosted_metrics_deploy is not defined
  39. - set_fact:
  40. openshift_hosted_metrics_duration: "{{ lookup('oo_option', 'openshift_hosted_metrics_duration') | default(7) }}"
  41. when: openshift_hosted_metrics_duration is not defined
  42. - set_fact:
  43. openshift_hosted_metrics_resolution: "{{ lookup('oo_option', 'openshift_hosted_metrics_resolution') | default('10s', true) }}"
  44. when: openshift_hosted_metrics_resolution is not defined
  45. roles:
  46. - openshift_facts
  47. post_tasks:
  48. - openshift_facts:
  49. role: master
  50. local_facts:
  51. api_port: "{{ openshift_master_api_port | default(None) }}"
  52. api_url: "{{ openshift_master_api_url | default(None) }}"
  53. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  54. controllers_port: "{{ openshift_master_controllers_port | default(None) }}"
  55. public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
  56. cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
  57. cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
  58. console_path: "{{ openshift_master_console_path | default(None) }}"
  59. console_port: "{{ openshift_master_console_port | default(None) }}"
  60. console_url: "{{ openshift_master_console_url | default(None) }}"
  61. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  62. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  63. ha: "{{ openshift_master_ha | default(groups.oo_masters | length > 1) }}"
  64. master_count: "{{ openshift_master_count | default(groups.oo_masters | length) }}"
  65. - openshift_facts:
  66. role: hosted
  67. openshift_env:
  68. openshift_hosted_registry_storage_kind: 'nfs'
  69. when: openshift_hosted_registry_storage_kind is not defined and groups.oo_nfs_to_config is defined and groups.oo_nfs_to_config | length > 0
  70. - name: Check status of external etcd certificatees
  71. stat:
  72. path: "{{ openshift.common.config_base }}/master/{{ item }}"
  73. with_items:
  74. - master.etcd-client.crt
  75. - master.etcd-ca.crt
  76. register: g_external_etcd_cert_stat_result
  77. - set_fact:
  78. etcd_client_certs_missing: "{{ g_external_etcd_cert_stat_result.results
  79. | oo_collect(attribute='stat.exists')
  80. | list | intersect([false])}}"
  81. etcd_cert_subdir: openshift-master-{{ openshift.common.hostname }}
  82. etcd_cert_config_dir: "{{ openshift.common.config_base }}/master"
  83. etcd_cert_prefix: master.etcd-
  84. etcd_hostname: "{{ openshift.common.hostname }}"
  85. etcd_ip: "{{ openshift.common.ip }}"
  86. when: groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config
  87. - name: Create temp directory for syncing certs
  88. hosts: localhost
  89. connection: local
  90. become: no
  91. gather_facts: no
  92. tasks:
  93. - name: Create local temp directory for syncing certs
  94. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  95. register: g_master_mktemp
  96. changed_when: False
  97. - name: Configure etcd certificates
  98. hosts: oo_first_etcd
  99. vars:
  100. etcd_generated_certs_dir: /etc/etcd/generated_certs
  101. etcd_needing_client_certs: "{{ hostvars
  102. | oo_select_keys(groups['oo_masters_to_config'])
  103. | default([])
  104. | oo_filter_list(filter_attr='etcd_client_certs_missing') }}"
  105. sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}"
  106. roles:
  107. - openshift_etcd_certificates
  108. post_tasks:
  109. - name: Create a tarball of the etcd certs
  110. command: >
  111. tar -czvf {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz
  112. -C {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }} .
  113. args:
  114. creates: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  115. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  116. - name: Retrieve the etcd cert tarballs
  117. fetch:
  118. src: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  119. dest: "{{ sync_tmpdir }}/"
  120. flat: yes
  121. fail_on_missing: yes
  122. validate_checksum: yes
  123. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  124. - name: Copy the external etcd certs to the masters
  125. hosts: oo_masters_to_config
  126. vars:
  127. sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}"
  128. tasks:
  129. - name: Ensure certificate directory exists
  130. file:
  131. path: "{{ openshift.common.config_base }}/master"
  132. state: directory
  133. when: etcd_client_certs_missing is defined and etcd_client_certs_missing
  134. - name: Unarchive the tarball on the master
  135. unarchive:
  136. src: "{{ sync_tmpdir }}/{{ etcd_cert_subdir }}.tgz"
  137. dest: "{{ etcd_cert_config_dir }}"
  138. when: etcd_client_certs_missing is defined and etcd_client_certs_missing
  139. - file:
  140. path: "{{ etcd_cert_config_dir }}/{{ item }}"
  141. owner: root
  142. group: root
  143. mode: 0600
  144. with_items:
  145. - master.etcd-client.crt
  146. - master.etcd-client.key
  147. - master.etcd-ca.crt
  148. when: etcd_client_certs_missing is defined and etcd_client_certs_missing
  149. - name: Check for cached session secrets
  150. hosts: oo_first_master
  151. roles:
  152. - role: openshift_facts
  153. post_tasks:
  154. - openshift_facts:
  155. role: master
  156. local_facts:
  157. session_auth_secrets: "{{ openshift_master_session_auth_secrets | default(openshift.master.session_auth_secrets | default(None)) }}"
  158. session_encryption_secrets: "{{ openshift_master_session_encryption_secrets | default(openshift.master.session_encryption_secrets | default(None)) }}"
  159. - name: Generate master session secrets
  160. hosts: oo_first_master
  161. vars:
  162. g_session_secrets_present: "{{ (openshift.master.session_auth_secrets | default([])) | length > 0 and (openshift.master.session_encryption_secrets | default([])) | length > 0 }}"
  163. g_session_auth_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  164. g_session_encryption_secrets: "{{ [ 24 | oo_generate_secret ] }}"
  165. roles:
  166. - role: openshift_facts
  167. tasks:
  168. - openshift_facts:
  169. role: master
  170. local_facts:
  171. session_auth_secrets: "{{ g_session_auth_secrets }}"
  172. session_encryption_secrets: "{{ g_session_encryption_secrets }}"
  173. when: not g_session_secrets_present | bool
  174. - name: Parse named certificates
  175. hosts: localhost
  176. connection: local
  177. become: no
  178. vars:
  179. internal_hostnames: "{{ hostvars[groups.oo_first_master.0].openshift.common.internal_hostnames }}"
  180. named_certificates: "{{ hostvars[groups.oo_first_master.0].openshift_master_named_certificates | default([]) }}"
  181. named_certificates_dir: "{{ hostvars[groups.oo_first_master.0].openshift.common.config_base }}/master/named_certificates/"
  182. tasks:
  183. - set_fact:
  184. parsed_named_certificates: "{{ named_certificates | oo_parse_named_certificates(named_certificates_dir, internal_hostnames) }}"
  185. when: named_certificates | length > 0
  186. - name: Deploy named certificates
  187. hosts: oo_masters_to_config
  188. vars:
  189. named_certs_dir: "{{ openshift.common.config_base }}/master/named_certificates/"
  190. named_certs_specified: "{{ openshift_master_named_certificates is defined }}"
  191. overwrite_named_certs: "{{ openshift_master_overwrite_named_certificates | default(false) }}"
  192. roles:
  193. - role: openshift_facts
  194. post_tasks:
  195. - openshift_facts:
  196. role: master
  197. local_facts:
  198. named_certificates: "{{ hostvars.localhost.parsed_named_certificates | default([]) }}"
  199. additive_facts_to_overwrite:
  200. - "{{ 'master.named_certificates' if overwrite_named_certs | bool else omit }}"
  201. - name: Clear named certificates
  202. file:
  203. path: "{{ named_certs_dir }}"
  204. state: absent
  205. when: overwrite_named_certs | bool
  206. - name: Ensure named certificate directory exists
  207. file:
  208. path: "{{ named_certs_dir }}"
  209. state: directory
  210. mode: 0700
  211. when: named_certs_specified | bool
  212. - name: Land named certificates
  213. copy: src="{{ item.certfile }}" dest="{{ named_certs_dir }}"
  214. with_items: "{{ openshift_master_named_certificates }}"
  215. when: named_certs_specified | bool
  216. - name: Land named certificate keys
  217. copy: src="{{ item.keyfile }}" dest="{{ named_certs_dir }}" mode=0600
  218. with_items: "{{ openshift_master_named_certificates }}"
  219. when: named_certs_specified | bool
  220. - name: Configure masters
  221. hosts: oo_masters_to_config
  222. any_errors_fatal: true
  223. vars:
  224. sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}"
  225. openshift_master_ha: "{{ openshift.master.ha }}"
  226. openshift_master_count: "{{ openshift.master.master_count }}"
  227. openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
  228. openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
  229. openshift_no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']
  230. | union(groups['oo_masters_to_config'])
  231. | union(groups['oo_etcd_to_config'] | default([])))
  232. | oo_collect('openshift.common.hostname') | default([]) | join (',')
  233. }}"
  234. when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and
  235. openshift_generate_no_proxy_hosts | default(True) | bool }}"
  236. roles:
  237. - role: openshift_master_facts
  238. - role: openshift_hosted_facts
  239. - role: openshift_master_certificates
  240. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  241. openshift_master_etcd_hosts: "{{ hostvars
  242. | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  243. | oo_collect('openshift.common.hostname')
  244. | default(none, true) }}"
  245. openshift_master_hostnames: "{{ hostvars
  246. | oo_select_keys(groups['oo_masters_to_config'] | default([]))
  247. | oo_collect('openshift.common.all_hostnames')
  248. | oo_flatten | unique }}"
  249. - role: openshift_clock
  250. - role: openshift_cloud_provider
  251. - role: openshift_builddefaults
  252. - role: os_firewall
  253. os_firewall_allow:
  254. - service: etcd embedded
  255. port: 4001/tcp
  256. - service: api server https
  257. port: "{{ openshift.master.api_port }}/tcp"
  258. - service: api controllers https
  259. port: "{{ openshift.master.controllers_port }}/tcp"
  260. - service: skydns tcp
  261. port: "{{ openshift.master.dns_port }}/tcp"
  262. - service: skydns udp
  263. port: "{{ openshift.master.dns_port }}/udp"
  264. - service: Fluentd td-agent tcp
  265. port: 24224/tcp
  266. - service: Fluentd td-agent udp
  267. port: 24224/udp
  268. - service: pcsd
  269. port: 2224/tcp
  270. - service: Corosync UDP
  271. port: 5404/udp
  272. - service: Corosync UDP
  273. port: 5405/udp
  274. - role: openshift_master
  275. openshift_master_hosts: "{{ groups.oo_masters_to_config }}"
  276. - role: nickhammond.logrotate
  277. - role: nuage_master
  278. when: openshift.common.use_nuage | bool
  279. post_tasks:
  280. - name: Create group for deployment type
  281. group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }}
  282. changed_when: False
  283. - name: Delete temporary directory on localhost
  284. hosts: localhost
  285. connection: local
  286. become: no
  287. gather_facts: no
  288. tasks:
  289. - file: name={{ g_master_mktemp.stdout }} state=absent
  290. changed_when: False