main.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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: Set atomic-guest tuned profile
  39. command: "tuned-adm profile atomic-guest"
  40. when: openshift.common.is_atomic | bool
  41. - name: Install sdn-ovs package
  42. 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"
  43. when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool
  44. - name: Pull node image
  45. command: >
  46. docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }}
  47. register: pull_result
  48. changed_when: "'Downloaded newer image' in pull_result.stdout"
  49. when: openshift.common.is_containerized | bool
  50. - name: Pull OpenVSwitch image
  51. command: >
  52. docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }}
  53. register: pull_result
  54. changed_when: "'Downloaded newer image' in pull_result.stdout"
  55. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  56. - name: Install the systemd units
  57. include: systemd_units.yml
  58. # The atomic-openshift-node service will set this parameter on
  59. # startup, but if the network service is restarted this setting is
  60. # lost. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1372388
  61. - name: Persist net.ipv4.ip_forward sysctl entry
  62. sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes state=present reload=yes
  63. - name: Start and enable openvswitch docker service
  64. service: name=openvswitch.service enabled=yes state=started
  65. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  66. register: ovs_start_result
  67. - set_fact:
  68. ovs_service_status_changed: "{{ ovs_start_result | changed }}"
  69. - file:
  70. dest: "{{ (openshift_node_kubelet_args|default({'config':None})).config}}"
  71. state: directory
  72. when: openshift_node_kubelet_args is defined and 'config' in openshift_node_kubelet_args
  73. # TODO: add the validate parameter when there is a validation command to run
  74. - name: Create the Node config
  75. template:
  76. dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
  77. src: node.yaml.v1.j2
  78. backup: true
  79. owner: root
  80. group: root
  81. mode: 0600
  82. notify:
  83. - restart node
  84. - name: Configure AWS Cloud Provider Settings
  85. lineinfile:
  86. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  87. regexp: "{{ item.regex }}"
  88. line: "{{ item.line }}"
  89. create: true
  90. with_items:
  91. - regex: '^AWS_ACCESS_KEY_ID='
  92. line: "AWS_ACCESS_KEY_ID={{ openshift_cloudprovider_aws_access_key | default('') }}"
  93. - regex: '^AWS_SECRET_ACCESS_KEY='
  94. line: "AWS_SECRET_ACCESS_KEY={{ openshift_cloudprovider_aws_secret_key | default('') }}"
  95. no_log: True
  96. 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"
  97. notify:
  98. - restart node
  99. - name: Configure Node Environment Variables
  100. lineinfile:
  101. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  102. regexp: "^{{ item.key }}="
  103. line: "{{ item.key }}={{ item.value }}"
  104. create: true
  105. with_dict: "{{ openshift.node.env_vars | default({}) }}"
  106. notify:
  107. - restart node
  108. - name: NFS storage plugin configuration
  109. include: storage_plugins/nfs.yml
  110. tags:
  111. - nfs
  112. - name: GlusterFS storage plugin configuration
  113. include: storage_plugins/glusterfs.yml
  114. when: "'glusterfs' in openshift.node.storage_plugin_deps"
  115. - name: Ceph storage plugin configuration
  116. include: storage_plugins/ceph.yml
  117. when: "'ceph' in openshift.node.storage_plugin_deps"
  118. - name: iSCSI storage plugin configuration
  119. include: storage_plugins/iscsi.yml
  120. when: "'iscsi' in openshift.node.storage_plugin_deps"
  121. # Necessary because when you're on a node that's also a master the master will be
  122. # restarted after the node restarts docker and it will take up to 60 seconds for
  123. # systemd to start the master again
  124. - name: Wait for master API to become available before proceeding
  125. # Using curl here since the uri module requires python-httplib2 and
  126. # wait_for port doesn't provide health information.
  127. command: >
  128. curl --silent --cacert {{ openshift.common.config_base }}/node/ca.crt
  129. {{ openshift_node_master_api_url }}/healthz/ready
  130. args:
  131. # Disables the following warning:
  132. # Consider using get_url or uri module rather than running curl
  133. warn: no
  134. register: api_available_output
  135. until: api_available_output.stdout == 'ok'
  136. retries: 120
  137. delay: 1
  138. changed_when: false
  139. when: openshift.common.is_containerized | bool
  140. - name: Start and enable node dep
  141. service: name={{ openshift.common.service_type }}-node-dep enabled=yes state=started
  142. when: openshift.common.is_containerized | bool
  143. - name: Start and enable node
  144. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  145. register: node_start_result
  146. until: not node_start_result | failed
  147. retries: 1
  148. delay: 30
  149. - set_fact:
  150. node_service_status_changed: "{{ node_start_result | changed }}"