config.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. ---
  2. - name: Gather and set facts for node hosts
  3. hosts: oo_nodes_to_config
  4. vars:
  5. t_oo_option_node_debug_level: "{{ lookup('oo_option', 'openshift_node_debug_level') }}"
  6. pre_tasks:
  7. - set_fact:
  8. openshift_node_debug_level: "{{ t_oo_option_node_debug_level }}"
  9. when: openshift_node_debug_level is not defined and t_oo_option_node_debug_level != ""
  10. roles:
  11. - openshift_facts
  12. tasks:
  13. # Since the master is generating the node certificates before they are
  14. # configured, we need to make sure to set the node properties beforehand if
  15. # we do not want the defaults
  16. - openshift_facts:
  17. role: node
  18. local_facts:
  19. labels: "{{ openshift_node_labels | default(None) }}"
  20. annotations: "{{ openshift_node_annotations | default(None) }}"
  21. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  22. - name: Create temp directory for syncing certs
  23. hosts: localhost
  24. connection: local
  25. become: no
  26. gather_facts: no
  27. tasks:
  28. - name: Create local temp directory for syncing certs
  29. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  30. register: mktemp
  31. changed_when: False
  32. - name: Evaluate node groups
  33. hosts: localhost
  34. become: no
  35. connection: local
  36. tasks:
  37. - name: Evaluate oo_containerized_master_nodes
  38. add_host:
  39. name: "{{ item }}"
  40. groups: oo_containerized_master_nodes
  41. ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
  42. ansible_become: "{{ g_sudo | default(omit) }}"
  43. with_items: "{{ groups.oo_nodes_to_config | default([]) }}"
  44. when: hostvars[item].openshift.common.is_containerized | bool and (item in groups.oo_nodes_to_config and item in groups.oo_masters_to_config)
  45. - name: Configure node instances
  46. hosts: oo_containerized_master_nodes
  47. serial: 1
  48. vars:
  49. openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}"
  50. openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}"
  51. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  52. openshift_no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']
  53. | union(groups['oo_masters_to_config'])
  54. | union(groups['oo_etcd_to_config'] | default([])))
  55. | oo_collect('openshift.common.hostname') | default([]) | join (',')
  56. }}"
  57. when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and
  58. openshift_generate_no_proxy_hosts | default(True) | bool }}"
  59. roles:
  60. - role: openshift_clock
  61. - role: openshift_docker
  62. - role: openshift_node_certificates
  63. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  64. - role: openshift_cloud_provider
  65. - role: openshift_common
  66. - role: openshift_node_dnsmasq
  67. when: openshift.common.use_dnsmasq
  68. - role: os_firewall
  69. os_firewall_allow:
  70. - service: Kubernetes kubelet
  71. port: 10250/tcp
  72. - service: http
  73. port: 80/tcp
  74. - service: https
  75. port: 443/tcp
  76. - service: Openshift kubelet ReadOnlyPort
  77. port: 10255/tcp
  78. - service: Openshift kubelet ReadOnlyPort udp
  79. port: 10255/udp
  80. - service: OpenShift OVS sdn
  81. port: 4789/udp
  82. when: openshift.node.use_openshift_sdn | bool
  83. - role: openshift_node
  84. - name: Configure node instances
  85. hosts: oo_nodes_to_config:!oo_containerized_master_nodes
  86. vars:
  87. openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}"
  88. openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}"
  89. openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}"
  90. openshift_no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']
  91. | union(groups['oo_masters_to_config'])
  92. | union(groups['oo_etcd_to_config'] | default([])))
  93. | oo_collect('openshift.common.hostname') | default([]) | join (',')
  94. }}"
  95. when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and
  96. openshift_generate_no_proxy_hosts | default(True) | bool }}"
  97. roles:
  98. - role: openshift_clock
  99. - role: openshift_docker
  100. - role: openshift_node_certificates
  101. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  102. - role: openshift_cloud_provider
  103. - role: openshift_common
  104. - role: openshift_node_dnsmasq
  105. when: openshift.common.use_dnsmasq
  106. - role: os_firewall
  107. os_firewall_allow:
  108. - service: Kubernetes kubelet
  109. port: 10250/tcp
  110. - service: http
  111. port: 80/tcp
  112. - service: https
  113. port: 443/tcp
  114. - service: Openshift kubelet ReadOnlyPort
  115. port: 10255/tcp
  116. - service: Openshift kubelet ReadOnlyPort udp
  117. port: 10255/udp
  118. - service: OpenShift OVS sdn
  119. port: 4789/udp
  120. when: openshift.node.use_openshift_sdn | bool
  121. - role: openshift_node
  122. - name: Gather and set facts for flannel certificatess
  123. hosts: oo_nodes_to_config
  124. tasks:
  125. - name: Check status of flannel external etcd certificates
  126. stat:
  127. path: "{{ openshift.common.config_base }}/node/{{ item }}"
  128. with_items:
  129. - node.etcd-client.crt
  130. - node.etcd-ca.crt
  131. register: g_external_etcd_flannel_cert_stat_result
  132. when: groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config and (openshift.common.use_flannel | bool)
  133. - set_fact:
  134. etcd_client_flannel_certs_missing: "{{ False in g_external_etcd_flannel_cert_stat_result.results
  135. | oo_collect(attribute='stat.exists')
  136. | list }}"
  137. etcd_cert_subdir: openshift-node-{{ openshift.common.hostname }}
  138. etcd_cert_config_dir: "{{ openshift.common.config_base }}/node"
  139. etcd_cert_prefix: node.etcd-
  140. etcd_hostname: "{{ openshift.common.hostname }}"
  141. etcd_ip: "{{ openshift.common.ip }}"
  142. when: groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 and (openshift.common.use_flannel | bool)
  143. - name: Configure flannel etcd certificates
  144. hosts: oo_first_etcd
  145. vars:
  146. etcd_generated_certs_dir: /etc/etcd/generated_certs
  147. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  148. pre_tasks:
  149. - set_fact:
  150. etcd_needing_client_certs: "{{ hostvars
  151. | oo_select_keys(groups['oo_nodes_to_config'])
  152. | oo_filter_list('etcd_client_flannel_certs_missing') | default([]) }}"
  153. roles:
  154. - role: openshift_etcd_certificates
  155. when: openshift_use_flannel | default(false) | bool
  156. post_tasks:
  157. - name: Create a tarball of the etcd flannel certs
  158. command: >
  159. tar -czvf {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz
  160. -C {{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }} .
  161. args:
  162. creates: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  163. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  164. - name: Retrieve the etcd cert tarballs
  165. fetch:
  166. src: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}.tgz"
  167. dest: "{{ sync_tmpdir }}/"
  168. flat: yes
  169. fail_on_missing: yes
  170. validate_checksum: yes
  171. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  172. - name: Copy the external etcd flannel certs to the nodes
  173. hosts: oo_nodes_to_config
  174. vars:
  175. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  176. tasks:
  177. - name: Ensure certificate directory exists
  178. file:
  179. path: "{{ openshift.common.config_base }}/node"
  180. state: directory
  181. when: etcd_client_flannel_certs_missing | default(false) | bool
  182. - name: Unarchive the tarball on the master
  183. unarchive:
  184. src: "{{ sync_tmpdir }}/{{ etcd_cert_subdir }}.tgz"
  185. dest: "{{ etcd_cert_config_dir }}"
  186. when: etcd_client_flannel_certs_missing | default(false) | bool
  187. - file:
  188. path: "{{ etcd_cert_config_dir }}/{{ item }}"
  189. owner: root
  190. group: root
  191. mode: 0600
  192. with_items:
  193. - node.etcd-client.crt
  194. - node.etcd-client.key
  195. - node.etcd-ca.crt
  196. when: etcd_client_flannel_certs_missing | default(false) | bool
  197. - name: Additional node config
  198. hosts: oo_nodes_to_config
  199. vars:
  200. # TODO: Prefix flannel role variables.
  201. openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}"
  202. etcd_urls: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls }}"
  203. embedded_etcd: "{{ hostvars[groups.oo_first_master.0].openshift.master.embedded_etcd }}"
  204. roles:
  205. - role: flannel
  206. when: openshift.common.use_flannel | bool
  207. - role: nuage_node
  208. when: openshift.common.use_nuage | bool
  209. - role: nickhammond.logrotate
  210. tasks:
  211. - name: Create group for deployment type
  212. group_by: key=oo_nodes_deployment_type_{{ openshift.common.deployment_type }}
  213. changed_when: False
  214. - name: Delete temporary directory on localhost
  215. hosts: localhost
  216. connection: local
  217. become: no
  218. gather_facts: no
  219. tasks:
  220. - file: name={{ mktemp.stdout }} state=absent
  221. changed_when: False
  222. - name: Set schedulability
  223. hosts: oo_first_master
  224. vars:
  225. openshift_nodes: "{{ hostvars
  226. | oo_select_keys(groups['oo_nodes_to_config'])
  227. | oo_collect('openshift.common.hostname') }}"
  228. openshift_node_vars: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']) }}"
  229. pre_tasks:
  230. # Necessary because when you're on a node that's also a master the master will be
  231. # restarted after the node restarts docker and it will take up to 60 seconds for
  232. # systemd to start the master again
  233. - name: Wait for master API to become available before proceeding
  234. # Using curl here since the uri module requires python-httplib2 and
  235. # wait_for port doesn't provide health information.
  236. command: >
  237. curl --silent --cacert {{ openshift.common.config_base }}/master/ca.crt
  238. {{ openshift.master.api_url }}/healthz/ready
  239. register: api_available_output
  240. until: api_available_output.stdout == 'ok'
  241. retries: 120
  242. delay: 1
  243. changed_when: false
  244. when: openshift.common.is_containerized | bool
  245. roles:
  246. - openshift_manage_node