main.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_gte_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. proxy_mode: "{{ openshift_node_proxy_mode | default('iptables') }}"
  36. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  37. # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
  38. - name: Install Node package
  39. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present"
  40. when: not openshift.common.is_containerized | bool
  41. - name: Install sdn-ovs package
  42. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} 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_version }}
  47. when: openshift.common.is_containerized | bool
  48. - name: Pull OpenVSwitch image
  49. command: >
  50. docker pull {{ openshift.node.ovs_image }}:{{ openshift_version }}
  51. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  52. - name: Install Node docker service file
  53. template:
  54. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node.service"
  55. src: openshift.docker.node.service
  56. register: install_node_result
  57. when: openshift.common.is_containerized | bool
  58. - name: Create the openvswitch service env file
  59. template:
  60. src: openvswitch.sysconfig.j2
  61. dest: /etc/sysconfig/openvswitch
  62. when: openshift.common.is_containerized | bool
  63. register: install_ovs_sysconfig
  64. - name: Install OpenvSwitch docker service file
  65. template:
  66. dest: "/etc/systemd/system/openvswitch.service"
  67. src: openvswitch.docker.service
  68. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  69. notify:
  70. - restart openvswitch
  71. - name: Reload systemd units
  72. command: systemctl daemon-reload
  73. when: openshift.common.is_containerized | bool and ( ( install_node_result | changed )
  74. or ( install_ovs_sysconfig | changed ) )
  75. - name: Start and enable openvswitch docker service
  76. service: name=openvswitch.service enabled=yes state=started
  77. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  78. register: ovs_start_result
  79. - set_fact:
  80. ovs_service_status_changed: "{{ ovs_start_result | changed }}"
  81. # TODO: add the validate parameter when there is a validation command to run
  82. - name: Create the Node config
  83. template:
  84. dest: "{{ openshift_node_config_file }}"
  85. src: node.yaml.v1.j2
  86. backup: true
  87. owner: root
  88. group: root
  89. mode: 0600
  90. notify:
  91. - restart node
  92. - name: Configure Node settings
  93. lineinfile:
  94. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  95. regexp: "{{ item.regex }}"
  96. line: "{{ item.line }}"
  97. create: true
  98. with_items:
  99. - regex: '^OPTIONS='
  100. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  101. - regex: '^CONFIG_FILE='
  102. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  103. - regex: '^IMAGE_VERSION='
  104. line: "IMAGE_VERSION={{ openshift_version }}"
  105. notify:
  106. - restart node
  107. - name: Additional storage plugin configuration
  108. include: storage_plugins/main.yml
  109. # Necessary because when you're on a node that's also a master the master will be
  110. # restarted after the node restarts docker and it will take up to 60 seconds for
  111. # systemd to start the master again
  112. - name: Wait for master API to become available before proceeding
  113. # Using curl here since the uri module requires python-httplib2 and
  114. # wait_for port doesn't provide health information.
  115. command: >
  116. curl -k --silent {{ openshift_node_master_api_url }}/healthz/ready
  117. register: api_available_output
  118. until: api_available_output.stdout == 'ok'
  119. retries: 120
  120. delay: 1
  121. changed_when: false
  122. when: openshift.common.is_containerized | bool
  123. - name: Start and enable node
  124. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  125. register: node_start_result
  126. - set_fact:
  127. node_service_status_changed: "{{ node_start_result | changed }}"