config.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 defined and 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: Additional node config
  123. hosts: oo_nodes_to_config
  124. vars:
  125. openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}"
  126. roles:
  127. - role: flannel
  128. etcd_urls: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls }}"
  129. embedded_etcd: "{{ hostvars[groups.oo_first_master.0].openshift.master.embedded_etcd }}"
  130. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  131. etcd_cert_subdir: "openshift-node-{{ openshift.common.hostname }}"
  132. etcd_cert_config_dir: "{{ openshift.common.config_base }}/node"
  133. when: openshift.common.use_flannel | bool
  134. - role: nuage_node
  135. when: openshift.common.use_nuage | bool
  136. - role: nickhammond.logrotate
  137. tasks:
  138. - name: Create group for deployment type
  139. group_by: key=oo_nodes_deployment_type_{{ openshift.common.deployment_type }}
  140. changed_when: False
  141. - name: Delete temporary directory on localhost
  142. hosts: localhost
  143. connection: local
  144. become: no
  145. gather_facts: no
  146. tasks:
  147. - file: name={{ mktemp.stdout }} state=absent
  148. changed_when: False
  149. - name: Set schedulability
  150. hosts: oo_first_master
  151. vars:
  152. openshift_nodes: "{{ groups.oo_nodes_to_config | default([]) }}"
  153. pre_tasks:
  154. # Necessary because when you're on a node that's also a master the master will be
  155. # restarted after the node restarts docker and it will take up to 60 seconds for
  156. # systemd to start the master again
  157. - name: Wait for master API to become available before proceeding
  158. # Using curl here since the uri module requires python-httplib2 and
  159. # wait_for port doesn't provide health information.
  160. command: >
  161. curl --silent
  162. {% if openshift.common.version_gte_3_2_or_1_2 | bool %}
  163. --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
  164. {% else %}
  165. --cacert {{ openshift.common.config_base }}/master/ca.crt
  166. {% endif %}
  167. {{ openshift.master.api_url }}/healthz/ready
  168. args:
  169. # Disables the following warning:
  170. # Consider using get_url or uri module rather than running curl
  171. warn: no
  172. register: api_available_output
  173. until: api_available_output.stdout == 'ok'
  174. retries: 120
  175. delay: 1
  176. changed_when: false
  177. when: openshift.common.is_containerized | bool
  178. roles:
  179. - openshift_manage_node