main.yml 5.2 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: Get docker images
  44. command: docker images
  45. changed_when: false
  46. when: openshift.common.is_containerized | bool
  47. register: docker_images
  48. - name: Pull required docker image
  49. command: >
  50. docker pull {{ openshift.node.node_image }}
  51. when: openshift.common.is_containerized | bool and openshift.node.node_image not in docker_images.stdout
  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 openshift.common.data_dir
  59. file:
  60. path: openshift.common.data_dir
  61. state: directory
  62. mode: 0755
  63. owner: root
  64. group: root
  65. when: openshift.common.is_containerized | bool
  66. - name: Pull required docker image
  67. command: >
  68. docker pull {{ openshift.node.ovs_image }}
  69. when: openshift.common.is_containerized | bool and openshift.node.ovs_image not in docker_images.stdout
  70. - name: Install OpenvSwitch docker service file
  71. template:
  72. dest: "/etc/systemd/system/openvswitch.service"
  73. src: openvswitch.docker.service
  74. register: install_ovs_result
  75. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  76. - name: Reload systemd units
  77. command: systemctl daemon-reload
  78. when: openshift.common.is_containerized and ( ( install_node_result | changed )
  79. or ( install_ovs_result | changed ) )
  80. - name: Start and enable openvswitch docker service
  81. service: name=openvswitch.service enabled=yes state=started
  82. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  83. # TODO: add the validate parameter when there is a validation command to run
  84. - name: Create the Node config
  85. template:
  86. dest: "{{ openshift_node_config_file }}"
  87. src: node.yaml.v1.j2
  88. backup: true
  89. notify:
  90. - restart node
  91. - name: Configure Node settings
  92. lineinfile:
  93. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  94. regexp: "{{ item.regex }}"
  95. line: "{{ item.line }}"
  96. create: true
  97. with_items:
  98. - regex: '^OPTIONS='
  99. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  100. - regex: '^CONFIG_FILE='
  101. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  102. notify:
  103. - restart node
  104. - name: Additional storage plugin configuration
  105. include: storage_plugins/main.yml
  106. - name: Start and enable node
  107. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  108. register: start_result
  109. - set_fact:
  110. node_service_status_changed: start_result | changed