main.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. - role: node
  12. local_facts:
  13. annotations: "{{ openshift_node_annotations | default(none) }}"
  14. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  15. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  16. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  17. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  18. registry_url: "{{ oreg_url | default(none) }}"
  19. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  20. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  21. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  22. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  23. node_image: "{{ osn_image | default(None) }}"
  24. ovs_image: "{{ osn_ovs_image | default(None) }}"
  25. proxy_mode: "{{ openshift_node_proxy_mode | default('iptables') }}"
  26. local_quota_per_fsgroup: "{{ openshift_node_local_quota_per_fsgroup | default(None) }}"
  27. dns_ip: "{{ openshift_dns_ip | default(none) | get_dns_ip(hostvars[inventory_hostname])}}"
  28. env_vars: "{{ openshift_node_env_vars | default(None) }}"
  29. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  30. # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
  31. - name: Install Node package
  32. 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"
  33. when: not openshift.common.is_containerized | bool
  34. - name: Install sdn-ovs package
  35. 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"
  36. when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool
  37. - name: Pull node image
  38. command: >
  39. docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }}
  40. register: pull_result
  41. changed_when: "'Downloaded newer image' in pull_result.stdout"
  42. when: openshift.common.is_containerized | bool
  43. - name: Pull OpenVSwitch image
  44. command: >
  45. docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }}
  46. register: pull_result
  47. changed_when: "'Downloaded newer image' in pull_result.stdout"
  48. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  49. - name: Install the systemd units
  50. include: systemd_units.yml
  51. - name: Start and enable openvswitch docker service
  52. service: name=openvswitch.service enabled=yes state=started
  53. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  54. register: ovs_start_result
  55. - set_fact:
  56. ovs_service_status_changed: "{{ ovs_start_result | changed }}"
  57. # TODO: add the validate parameter when there is a validation command to run
  58. - name: Create the Node config
  59. template:
  60. dest: "{{ openshift_node_config_file }}"
  61. src: node.yaml.v1.j2
  62. backup: true
  63. owner: root
  64. group: root
  65. mode: 0600
  66. notify:
  67. - restart node
  68. - name: Configure AWS Cloud Provider Settings
  69. lineinfile:
  70. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  71. regexp: "{{ item.regex }}"
  72. line: "{{ item.line }}"
  73. create: true
  74. with_items:
  75. - regex: '^AWS_ACCESS_KEY_ID='
  76. line: "AWS_ACCESS_KEY_ID={{ openshift_cloudprovider_aws_access_key }}"
  77. - regex: '^AWS_SECRET_ACCESS_KEY='
  78. line: "AWS_SECRET_ACCESS_KEY={{ openshift_cloudprovider_aws_secret_key }}"
  79. 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"
  80. notify:
  81. - restart node
  82. - name: Configure Node Environment Variables
  83. lineinfile:
  84. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  85. regexp: "^{{ item.key }}="
  86. line: "{{ item.key }}={{ item.value }}"
  87. create: true
  88. with_dict: "{{ openshift.node.env_vars | default({}) }}"
  89. notify:
  90. - restart node
  91. - name: NFS storage plugin configuration
  92. include: storage_plugins/nfs.yml
  93. - name: GlusterFS storage plugin configuration
  94. include: storage_plugins/glusterfs.yml
  95. when: "'glusterfs' in openshift.node.storage_plugin_deps"
  96. - name: Ceph storage plugin configuration
  97. include: storage_plugins/ceph.yml
  98. when: "'ceph' in openshift.node.storage_plugin_deps"
  99. - name: iSCSI storage plugin configuration
  100. include: storage_plugins/iscsi.yml
  101. when: "'iscsi' in openshift.node.storage_plugin_deps"
  102. # Necessary because when you're on a node that's also a master the master will be
  103. # restarted after the node restarts docker and it will take up to 60 seconds for
  104. # systemd to start the master again
  105. - name: Wait for master API to become available before proceeding
  106. # Using curl here since the uri module requires python-httplib2 and
  107. # wait_for port doesn't provide health information.
  108. command: >
  109. curl --silent --cacert {{ openshift.common.config_base }}/node/ca.crt
  110. {{ openshift_node_master_api_url }}/healthz/ready
  111. register: api_available_output
  112. until: api_available_output.stdout == 'ok'
  113. retries: 120
  114. delay: 1
  115. changed_when: false
  116. when: openshift.common.is_containerized | bool
  117. - name: Start and enable node dep
  118. service: name={{ openshift.common.service_type }}-node-dep enabled=yes state=started
  119. when: openshift.common.is_containerized | bool
  120. - name: Start and enable node
  121. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  122. register: node_start_result
  123. ignore_errors: yes
  124. - name: Wait 30 seconds for docker initialization whenever node has failed
  125. pause:
  126. seconds: 30
  127. when: node_start_result | failed
  128. - name: Start and enable node again
  129. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  130. register: node_start_result
  131. when: node_start_result | failed
  132. - set_fact:
  133. node_service_status_changed: "{{ node_start_result | changed }}"