main.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ---
  2. # TODO: allow for overriding default ports where possible
  3. - fail:
  4. msg: "SELinux is disabled, This deployment type requires that SELinux is enabled."
  5. when: >
  6. (not ansible_selinux or ansible_selinux.status != 'enabled') and
  7. deployment_type in ['enterprise', 'online', 'atomic-enterprise', 'openshift-enterprise']
  8. - name: Set node facts
  9. openshift_facts:
  10. role: "{{ item.role }}"
  11. local_facts: "{{ item.local_facts }}"
  12. with_items:
  13. # Reset node labels to an empty dictionary.
  14. - role: node
  15. local_facts:
  16. labels: {}
  17. - role: node
  18. local_facts:
  19. annotations: "{{ openshift_node_annotations | default(none) }}"
  20. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  21. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  22. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  23. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  24. registry_url: "{{ oreg_url | default(none) }}"
  25. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  26. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  27. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  28. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  29. node_image: "{{ osn_image | default(None) }}"
  30. ovs_image: "{{ osn_ovs_image | default(None) }}"
  31. proxy_mode: "{{ openshift_node_proxy_mode | default('iptables') }}"
  32. local_quota_per_fsgroup: "{{ openshift_node_local_quota_per_fsgroup | default(None) }}"
  33. dns_ip: "{{ openshift_dns_ip | default(none) | get_dns_ip(hostvars[inventory_hostname])}}"
  34. env_vars: "{{ openshift_node_env_vars | default(None) }}"
  35. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  36. # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
  37. - name: Install Node package
  38. package:
  39. name: "{{ openshift.common.service_type }}-node{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}"
  40. state: present
  41. when: not openshift.common.is_containerized | bool
  42. - name: Check for tuned package
  43. command: rpm -q tuned
  44. args:
  45. warn: no
  46. register: tuned_installed
  47. changed_when: false
  48. failed_when: false
  49. - name: Set atomic-guest tuned profile
  50. command: "tuned-adm profile atomic-guest"
  51. when: tuned_installed.rc == 0 and openshift.common.is_atomic | bool
  52. - name: Install sdn-ovs package
  53. package:
  54. name: "{{ openshift.common.service_type }}-sdn-ovs{{ openshift_pkg_version | oo_image_tag_to_rpm_version(include_dash=True) }}"
  55. state: present
  56. when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool
  57. - name: Pull node image
  58. command: >
  59. docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }}
  60. register: pull_result
  61. changed_when: "'Downloaded newer image' in pull_result.stdout"
  62. when: openshift.common.is_containerized | bool
  63. - name: Pull OpenVSwitch image
  64. command: >
  65. docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }}
  66. register: pull_result
  67. changed_when: "'Downloaded newer image' in pull_result.stdout"
  68. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  69. - name: Install the systemd units
  70. include: systemd_units.yml
  71. # The atomic-openshift-node service will set this parameter on
  72. # startup, but if the network service is restarted this setting is
  73. # lost. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1372388
  74. - name: Persist net.ipv4.ip_forward sysctl entry
  75. sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes state=present reload=yes
  76. - name: Start and enable openvswitch docker service
  77. systemd:
  78. name: openvswitch.service
  79. enabled: yes
  80. state: started
  81. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  82. register: ovs_start_result
  83. - set_fact:
  84. ovs_service_status_changed: "{{ ovs_start_result | changed }}"
  85. - file:
  86. dest: "{{ (openshift_node_kubelet_args|default({'config':None})).config}}"
  87. state: directory
  88. when: openshift_node_kubelet_args is defined and 'config' in openshift_node_kubelet_args
  89. # TODO: add the validate parameter when there is a validation command to run
  90. - name: Create the Node config
  91. template:
  92. dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
  93. src: node.yaml.v1.j2
  94. backup: true
  95. owner: root
  96. group: root
  97. mode: 0600
  98. notify:
  99. - restart node
  100. - name: Configure AWS Cloud Provider Settings
  101. lineinfile:
  102. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  103. regexp: "{{ item.regex }}"
  104. line: "{{ item.line }}"
  105. create: true
  106. with_items:
  107. - regex: '^AWS_ACCESS_KEY_ID='
  108. line: "AWS_ACCESS_KEY_ID={{ openshift_cloudprovider_aws_access_key | default('') }}"
  109. - regex: '^AWS_SECRET_ACCESS_KEY='
  110. line: "AWS_SECRET_ACCESS_KEY={{ openshift_cloudprovider_aws_secret_key | default('') }}"
  111. no_log: True
  112. when: "openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined"
  113. notify:
  114. - restart node
  115. - name: Configure Node Environment Variables
  116. lineinfile:
  117. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  118. regexp: "^{{ item.key }}="
  119. line: "{{ item.key }}={{ item.value }}"
  120. create: true
  121. with_dict: "{{ openshift.node.env_vars | default({}) }}"
  122. notify:
  123. - restart node
  124. - name: NFS storage plugin configuration
  125. include: storage_plugins/nfs.yml
  126. tags:
  127. - nfs
  128. - name: GlusterFS storage plugin configuration
  129. include: storage_plugins/glusterfs.yml
  130. when: "'glusterfs' in openshift.node.storage_plugin_deps"
  131. - name: Ceph storage plugin configuration
  132. include: storage_plugins/ceph.yml
  133. when: "'ceph' in openshift.node.storage_plugin_deps"
  134. - name: iSCSI storage plugin configuration
  135. include: storage_plugins/iscsi.yml
  136. when: "'iscsi' in openshift.node.storage_plugin_deps"
  137. # Necessary because when you're on a node that's also a master the master will be
  138. # restarted after the node restarts docker and it will take up to 60 seconds for
  139. # systemd to start the master again
  140. - name: Wait for master API to become available before proceeding
  141. # Using curl here since the uri module requires python-httplib2 and
  142. # wait_for port doesn't provide health information.
  143. command: >
  144. curl --silent --cacert {{ openshift.common.config_base }}/node/ca.crt
  145. {{ openshift_node_master_api_url }}/healthz/ready
  146. args:
  147. # Disables the following warning:
  148. # Consider using get_url or uri module rather than running curl
  149. warn: no
  150. register: api_available_output
  151. until: api_available_output.stdout == 'ok'
  152. retries: 120
  153. delay: 1
  154. changed_when: false
  155. when: openshift.common.is_containerized | bool
  156. - name: Start and enable node dep
  157. systemd:
  158. name: "{{ openshift.common.service_type }}-node-dep"
  159. enabled: yes
  160. state: started
  161. when: openshift.common.is_containerized | bool
  162. - name: Start and enable node
  163. systemd:
  164. name: "{{ openshift.common.service_type }}-node"
  165. enabled: yes
  166. state: started
  167. register: node_start_result
  168. until: not node_start_result | failed
  169. retries: 1
  170. delay: 30
  171. - set_fact:
  172. node_service_status_changed: "{{ node_start_result | changed }}"