main.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. docker_log_driver: "{{ lookup( 'oo_option' , 'docker_log_driver' ) | default('',True) }}"
  25. docker_log_options: "{{ lookup( 'oo_option' , 'docker_log_options' ) | default('',True) }}"
  26. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  27. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  28. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  29. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  30. registry_url: "{{ oreg_url | default(none) }}"
  31. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  32. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  33. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  34. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  35. node_image: "{{ osn_image | default(None) }}"
  36. ovs_image: "{{ osn_ovs_image | default(None) }}"
  37. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  38. # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging.
  39. - name: Install Node package
  40. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present"
  41. when: not openshift.common.is_containerized | bool
  42. - name: Install sdn-ovs package
  43. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present"
  44. when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool
  45. - name: Get docker images
  46. command: docker images
  47. changed_when: false
  48. when: openshift.common.is_containerized | bool
  49. register: docker_images
  50. - name: Pull required docker image
  51. command: >
  52. docker pull {{ openshift.node.node_image }}
  53. when: openshift.common.is_containerized | bool and openshift.node.node_image not in docker_images.stdout
  54. - name: Install Node docker service file
  55. template:
  56. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node.service"
  57. src: openshift.docker.node.service
  58. register: install_node_result
  59. when: openshift.common.is_containerized | bool
  60. - name: Create openshift.common.data_dir
  61. file:
  62. path: openshift.common.data_dir
  63. state: directory
  64. mode: 0755
  65. owner: root
  66. group: root
  67. when: openshift.common.is_containerized | bool
  68. - name: Pull required docker image
  69. command: >
  70. docker pull {{ openshift.node.ovs_image }}
  71. when: openshift.common.is_containerized | bool and openshift.node.ovs_image not in docker_images.stdout
  72. - name: Install OpenvSwitch docker service file
  73. template:
  74. dest: "/etc/systemd/system/openvswitch.service"
  75. src: openvswitch.docker.service
  76. register: install_ovs_result
  77. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  78. - name: Reload systemd units
  79. command: systemctl daemon-reload
  80. when: openshift.common.is_containerized and ( ( install_node_result | changed )
  81. or ( install_ovs_result | changed ) )
  82. - name: Start and enable openvswitch docker service
  83. service: name=openvswitch.service enabled=yes state=started
  84. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  85. # TODO: add the validate parameter when there is a validation command to run
  86. - name: Create the Node config
  87. template:
  88. dest: "{{ openshift_node_config_file }}"
  89. src: node.yaml.v1.j2
  90. backup: true
  91. notify:
  92. - restart node
  93. - name: Configure Node settings
  94. lineinfile:
  95. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  96. regexp: "{{ item.regex }}"
  97. line: "{{ item.line }}"
  98. create: true
  99. with_items:
  100. - regex: '^OPTIONS='
  101. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  102. - regex: '^CONFIG_FILE='
  103. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  104. notify:
  105. - restart node
  106. - name: Additional storage plugin configuration
  107. include: storage_plugins/main.yml
  108. - name: Start and enable node
  109. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  110. register: start_result
  111. - set_fact:
  112. node_service_status_changed: start_result | changed