main.yml 7.4 KB

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