config.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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: Configure masters
  175. hosts: oo_masters_to_config
  176. any_errors_fatal: true
  177. vars:
  178. sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}"
  179. openshift_master_ha: "{{ openshift.master.ha }}"
  180. openshift_master_count: "{{ openshift.master.master_count }}"
  181. openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
  182. openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
  183. openshift_no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']
  184. | union(groups['oo_masters_to_config'])
  185. | union(groups['oo_etcd_to_config'] | default([])))
  186. | oo_collect('openshift.common.hostname') | default([]) | join (',')
  187. }}"
  188. when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and
  189. openshift_generate_no_proxy_hosts | default(True) | bool }}"
  190. roles:
  191. - role: openshift_master_facts
  192. - role: openshift_hosted_facts
  193. - role: openshift_master_certificates
  194. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  195. openshift_master_etcd_hosts: "{{ hostvars
  196. | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  197. | oo_collect('openshift.common.hostname')
  198. | default(none, true) }}"
  199. openshift_master_hostnames: "{{ hostvars
  200. | oo_select_keys(groups['oo_masters_to_config'] | default([]))
  201. | oo_collect('openshift.common.all_hostnames')
  202. | oo_flatten | unique }}"
  203. - role: openshift_clock
  204. - role: openshift_cloud_provider
  205. - role: openshift_builddefaults
  206. - role: os_firewall
  207. os_firewall_allow:
  208. - service: etcd embedded
  209. port: 4001/tcp
  210. - service: api server https
  211. port: "{{ openshift.master.api_port }}/tcp"
  212. - service: api controllers https
  213. port: "{{ openshift.master.controllers_port }}/tcp"
  214. - service: skydns tcp
  215. port: "{{ openshift.master.dns_port }}/tcp"
  216. - service: skydns udp
  217. port: "{{ openshift.master.dns_port }}/udp"
  218. - service: Fluentd td-agent tcp
  219. port: 24224/tcp
  220. - service: Fluentd td-agent udp
  221. port: 24224/udp
  222. - service: pcsd
  223. port: 2224/tcp
  224. - service: Corosync UDP
  225. port: 5404/udp
  226. - service: Corosync UDP
  227. port: 5405/udp
  228. - role: openshift_master
  229. openshift_master_hosts: "{{ groups.oo_masters_to_config }}"
  230. - role: nickhammond.logrotate
  231. - role: nuage_master
  232. when: openshift.common.use_nuage | bool
  233. post_tasks:
  234. - name: Create group for deployment type
  235. group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }}
  236. changed_when: False
  237. - name: Delete temporary directory on localhost
  238. hosts: localhost
  239. connection: local
  240. become: no
  241. gather_facts: no
  242. tasks:
  243. - file: name={{ g_master_mktemp.stdout }} state=absent
  244. changed_when: False