main.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. # TODO: add the validate parameter when there is a validation command to run
  70. - name: Create the Node config
  71. template:
  72. dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
  73. src: node.yaml.v1.j2
  74. backup: true
  75. owner: root
  76. group: root
  77. mode: 0600
  78. notify:
  79. - restart node
  80. - name: Configure AWS Cloud Provider Settings
  81. lineinfile:
  82. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  83. regexp: "{{ item.regex }}"
  84. line: "{{ item.line }}"
  85. create: true
  86. with_items:
  87. - regex: '^AWS_ACCESS_KEY_ID='
  88. line: "AWS_ACCESS_KEY_ID={{ openshift_cloudprovider_aws_access_key | default('') }}"
  89. - regex: '^AWS_SECRET_ACCESS_KEY='
  90. line: "AWS_SECRET_ACCESS_KEY={{ openshift_cloudprovider_aws_secret_key | default('') }}"
  91. no_log: True
  92. 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"
  93. notify:
  94. - restart node
  95. - name: Configure Node Environment Variables
  96. lineinfile:
  97. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  98. regexp: "^{{ item.key }}="
  99. line: "{{ item.key }}={{ item.value }}"
  100. create: true
  101. with_dict: "{{ openshift.node.env_vars | default({}) }}"
  102. notify:
  103. - restart node
  104. - name: NFS storage plugin configuration
  105. include: storage_plugins/nfs.yml
  106. tags:
  107. - nfs
  108. - name: GlusterFS storage plugin configuration
  109. include: storage_plugins/glusterfs.yml
  110. when: "'glusterfs' in openshift.node.storage_plugin_deps"
  111. - name: Ceph storage plugin configuration
  112. include: storage_plugins/ceph.yml
  113. when: "'ceph' in openshift.node.storage_plugin_deps"
  114. - name: iSCSI storage plugin configuration
  115. include: storage_plugins/iscsi.yml
  116. when: "'iscsi' in openshift.node.storage_plugin_deps"
  117. # Necessary because when you're on a node that's also a master the master will be
  118. # restarted after the node restarts docker and it will take up to 60 seconds for
  119. # systemd to start the master again
  120. - name: Wait for master API to become available before proceeding
  121. # Using curl here since the uri module requires python-httplib2 and
  122. # wait_for port doesn't provide health information.
  123. command: >
  124. curl --silent --cacert {{ openshift.common.config_base }}/node/ca.crt
  125. {{ openshift_node_master_api_url }}/healthz/ready
  126. args:
  127. # Disables the following warning:
  128. # Consider using get_url or uri module rather than running curl
  129. warn: no
  130. register: api_available_output
  131. until: api_available_output.stdout == 'ok'
  132. retries: 120
  133. delay: 1
  134. changed_when: false
  135. when: openshift.common.is_containerized | bool
  136. - name: Start and enable node dep
  137. service: name={{ openshift.common.service_type }}-node-dep enabled=yes state=started
  138. when: openshift.common.is_containerized | bool
  139. - name: Start and enable node
  140. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  141. register: node_start_result
  142. until: not node_start_result | failed
  143. retries: 1
  144. delay: 30
  145. - set_fact:
  146. node_service_status_changed: "{{ node_start_result | changed }}"