main.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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: common
  12. local_facts:
  13. hostname: "{{ openshift_hostname | default(none) }}"
  14. public_hostname: "{{ openshift_public_hostname | default(none) }}"
  15. deployment_type: "{{ openshift_deployment_type }}"
  16. # TODO: Replace this with a lookup or filter plugin.
  17. dns_ip: "{{ openshift_dns_ip
  18. | default(openshift_master_cluster_vip
  19. | default(None if openshift.common.version_greater_than_3_1_or_1_1 | bool else openshift_node_first_master_ip | default(None, true), true), true) }}"
  20. - role: node
  21. local_facts:
  22. annotations: "{{ openshift_node_annotations | default(none) }}"
  23. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  24. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  25. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  26. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  27. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  28. registry_url: "{{ oreg_url | default(none) }}"
  29. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  30. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  31. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  32. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  33. node_image: "{{ osn_image | default(None) }}"
  34. ovs_image: "{{ osn_ovs_image | default(None) }}"
  35. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  36. # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
  37. - name: Install Node package
  38. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present"
  39. when: not openshift.common.is_containerized | bool
  40. - name: Install sdn-ovs package
  41. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present"
  42. when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool
  43. - name: Pull node image
  44. command: >
  45. docker pull {{ openshift.node.node_image }}
  46. when: openshift.common.is_containerized | bool
  47. - name: Pull OpenVSwitch image
  48. command: >
  49. docker pull {{ openshift.node.ovs_image }}
  50. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  51. - name: Install Node docker service file
  52. template:
  53. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node.service"
  54. src: openshift.docker.node.service
  55. register: install_node_result
  56. when: openshift.common.is_containerized | bool
  57. - name: Install OpenvSwitch docker service file
  58. template:
  59. dest: "/etc/systemd/system/openvswitch.service"
  60. src: openvswitch.docker.service
  61. register: install_ovs_result
  62. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  63. - name: Reload systemd units
  64. command: systemctl daemon-reload
  65. when: openshift.common.is_containerized and ( ( install_node_result | changed )
  66. or ( install_ovs_result | changed ) )
  67. - name: Start and enable openvswitch docker service
  68. service: name=openvswitch.service enabled=yes state=started
  69. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  70. # TODO: add the validate parameter when there is a validation command to run
  71. - name: Create the Node config
  72. template:
  73. dest: "{{ openshift_node_config_file }}"
  74. src: node.yaml.v1.j2
  75. backup: true
  76. notify:
  77. - restart node
  78. - name: Configure Node settings
  79. lineinfile:
  80. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  81. regexp: "{{ item.regex }}"
  82. line: "{{ item.line }}"
  83. create: true
  84. with_items:
  85. - regex: '^OPTIONS='
  86. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  87. - regex: '^CONFIG_FILE='
  88. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  89. notify:
  90. - restart node
  91. - name: Additional storage plugin configuration
  92. include: storage_plugins/main.yml
  93. # Necessary because when you're on a node that's also a master the master will be
  94. # restarted after the node restarts docker and it will take up to 60 seconds for
  95. # systemd to start the master again
  96. - name: Wait for master API to become available before proceeding
  97. # Using curl here since the uri module requires python-httplib2 and
  98. # wait_for port doesn't provide health information.
  99. command: >
  100. curl -k --head --silent {{ openshift_node_master_api_url }}
  101. register: api_available_output
  102. until: api_available_output.stdout.find("200 OK") != -1
  103. retries: 120
  104. delay: 1
  105. changed_when: false
  106. when: openshift.common.is_containerized | bool
  107. - name: Start and enable node
  108. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  109. register: start_result
  110. - set_fact:
  111. node_service_status_changed: "{{ start_result | changed }}"