main.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ---
  2. - debug: var=openshift_version
  3. # TODO: allow for overriding default ports where possible
  4. - fail:
  5. msg: "SELinux is disabled, This deployment type requires that SELinux is enabled."
  6. when: (not ansible_selinux or ansible_selinux.status != 'enabled') and deployment_type in ['enterprise', 'online', 'atomic-enterprise', 'openshift-enterprise']
  7. - name: Set node facts
  8. openshift_facts:
  9. role: "{{ item.role }}"
  10. local_facts: "{{ item.local_facts }}"
  11. with_items:
  12. - role: node
  13. local_facts:
  14. annotations: "{{ openshift_node_annotations | default(none) }}"
  15. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  16. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  17. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  18. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  19. registry_url: "{{ oreg_url | default(none) }}"
  20. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  21. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  22. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  23. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  24. node_image: "{{ osn_image | default(None) }}"
  25. ovs_image: "{{ osn_ovs_image | default(None) }}"
  26. proxy_mode: "{{ openshift_node_proxy_mode | default('iptables') }}"
  27. local_quota_per_fsgroup: "{{ openshift_node_local_quota_per_fsgroup | default(None) }}"
  28. dns_ip: "{{ openshift_dns_ip | default(none) | get_dns_ip(hostvars[inventory_hostname])}}"
  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_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_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_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 }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }}
  40. when: openshift.common.is_containerized | bool
  41. - name: Pull OpenVSwitch image
  42. command: >
  43. docker pull {{ openshift.node.ovs_image }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }}
  44. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  45. - name: Install the systemd units
  46. include: systemd_units.yml
  47. - name: Reload systemd units
  48. command: systemctl daemon-reload
  49. when: openshift.common.is_containerized | bool and (install_node_result | changed or install_ovs_sysconfig | changed or install_node_dep_result | changed)
  50. notify:
  51. - restart node
  52. - name: Start and enable openvswitch docker service
  53. service: name=openvswitch.service enabled=yes state=started
  54. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  55. register: ovs_start_result
  56. - set_fact:
  57. ovs_service_status_changed: "{{ ovs_start_result | changed }}"
  58. # TODO: add the validate parameter when there is a validation command to run
  59. - name: Create the Node config
  60. template:
  61. dest: "{{ openshift_node_config_file }}"
  62. src: node.yaml.v1.j2
  63. backup: true
  64. owner: root
  65. group: root
  66. mode: 0600
  67. notify:
  68. - restart node
  69. - name: Configure AWS Cloud Provider Settings
  70. lineinfile:
  71. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  72. regexp: "{{ item.regex }}"
  73. line: "{{ item.line }}"
  74. create: true
  75. with_items:
  76. - regex: '^AWS_ACCESS_KEY_ID='
  77. line: "AWS_ACCESS_KEY_ID={{ openshift.cloudprovider.aws.access_key }}"
  78. - regex: '^AWS_SECRET_ACCESS_KEY='
  79. line: "AWS_SECRET_ACCESS_KEY={{ openshift.cloudprovider.aws.secret_key }}"
  80. when: "'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws"
  81. notify:
  82. - restart node
  83. - name: Additional storage plugin configuration
  84. include: storage_plugins/main.yml
  85. # Necessary because when you're on a node that's also a master the master will be
  86. # restarted after the node restarts docker and it will take up to 60 seconds for
  87. # systemd to start the master again
  88. - name: Wait for master API to become available before proceeding
  89. # Using curl here since the uri module requires python-httplib2 and
  90. # wait_for port doesn't provide health information.
  91. command: >
  92. curl --silent --cacert {{ openshift.common.config_base }}/node/ca.crt
  93. {{ openshift_node_master_api_url }}/healthz/ready
  94. register: api_available_output
  95. until: api_available_output.stdout == 'ok'
  96. retries: 120
  97. delay: 1
  98. changed_when: false
  99. when: openshift.common.is_containerized | bool
  100. - name: Start and enable node
  101. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  102. register: node_start_result
  103. ignore_errors: yes
  104. - name: Check logs on failure
  105. command: journalctl -xe
  106. register: node_failure
  107. when: node_start_result | failed
  108. - name: Dump failure information
  109. debug: var=node_failure
  110. when: node_start_result | failed
  111. - set_fact:
  112. node_service_status_changed: "{{ node_start_result | changed }}"