main.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ---
  2. # TODO: allow for overriding default ports where possible
  3. - fail:
  4. msg: This role requres that osn_cluster_dns_domain is set
  5. when: osn_cluster_dns_domain is not defined or not osn_cluster_dns_domain
  6. - fail:
  7. msg: This role requres that osn_cluster_dns_ip is set
  8. when: osn_cluster_dns_ip is not defined or not osn_cluster_dns_ip
  9. - fail:
  10. msg: "SELinux is disabled, This deployment type requires that SELinux is enabled."
  11. when: (not ansible_selinux or ansible_selinux.status != 'enabled') and deployment_type in ['enterprise', 'online', 'atomic-enterprise', 'openshift-enterprise']
  12. - name: Set node facts
  13. openshift_facts:
  14. role: "{{ item.role }}"
  15. local_facts: "{{ item.local_facts }}"
  16. with_items:
  17. - role: common
  18. local_facts:
  19. hostname: "{{ openshift_hostname | default(none) }}"
  20. public_hostname: "{{ openshift_public_hostname | default(none) }}"
  21. deployment_type: "{{ openshift_deployment_type }}"
  22. - role: node
  23. local_facts:
  24. annotations: "{{ openshift_node_annotations | default(none) }}"
  25. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  26. docker_log_driver: "{{ lookup( 'oo_option' , 'docker_log_driver' ) | default('',True) }}"
  27. docker_log_options: "{{ lookup( 'oo_option' , 'docker_log_options' ) | default('',True) }}"
  28. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  29. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  30. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  31. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  32. registry_url: "{{ oreg_url | default(none) }}"
  33. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  34. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  35. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  36. set_node_ip: "{{ openshift_set_node_ip | 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.
  39. - name: Install Node package
  40. yum: pkg={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present
  41. when: ansible_pkg_mgr == "yum"
  42. register: node_install_result
  43. - name: Install Node package
  44. dnf: pkg={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present
  45. when: ansible_pkg_mgr == "dnf"
  46. register: node_install_result
  47. - name: Install sdn-ovs package
  48. yum: pkg={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present
  49. register: sdn_install_result
  50. when: ansible_pkg_mgr == "yum" and openshift.common.use_openshift_sdn
  51. - name: Install sdn-ovs package
  52. dnf: pkg={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present
  53. register: sdn_install_result
  54. when: ansible_pkg_mgr == "dnf" and openshift.common.use_openshift_sdn
  55. # TODO: add the validate parameter when there is a validation command to run
  56. - name: Create the Node config
  57. template:
  58. dest: "{{ openshift_node_config_file }}"
  59. src: node.yaml.v1.j2
  60. backup: true
  61. notify:
  62. - restart node
  63. - name: Configure Node settings
  64. lineinfile:
  65. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  66. regexp: "{{ item.regex }}"
  67. line: "{{ item.line }}"
  68. with_items:
  69. - regex: '^OPTIONS='
  70. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  71. - regex: '^CONFIG_FILE='
  72. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  73. notify:
  74. - restart node
  75. - stat: path=/etc/sysconfig/docker
  76. register: docker_check
  77. # TODO: Enable secure registry when code available in origin
  78. - name: Secure Registry and Logs Options
  79. lineinfile:
  80. dest: /etc/sysconfig/docker
  81. regexp: '^OPTIONS=.*$'
  82. line: "OPTIONS='--insecure-registry={{ openshift.node.portal_net }} \
  83. {% if ansible_selinux and ansible_selinux.status == '''enabled''' %}--selinux-enabled{% endif %} \
  84. {% if openshift.node.docker_log_driver is defined %} --log-driver {{ openshift.node.docker_log_driver }} {% endif %} \
  85. {% if openshift.node.docker_log_options is defined %} {{ openshift.node.docker_log_options | oo_split() | oo_prepend_strings_in_list('--log-opt ') | join(' ')}} {% endif %} '"
  86. when: docker_check.stat.isreg
  87. notify:
  88. - restart docker
  89. - set_fact:
  90. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  91. | oo_split() | union(['registry.access.redhat.com'])
  92. | difference(['']) }}"
  93. when: openshift.common.deployment_type == 'enterprise'
  94. - set_fact:
  95. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  96. | oo_split() | difference(['']) }}"
  97. when: openshift.common.deployment_type != 'enterprise'
  98. - name: Add personal registries
  99. lineinfile:
  100. dest: /etc/sysconfig/docker
  101. regexp: '^ADD_REGISTRY=.*$'
  102. line: "ADD_REGISTRY='{{ docker_additional_registries
  103. | oo_prepend_strings_in_list('--add-registry ') | join(' ') }}'"
  104. when: docker_check.stat.isreg and docker_additional_registries
  105. notify:
  106. - restart docker
  107. - name: Block registries
  108. lineinfile:
  109. dest: /etc/sysconfig/docker
  110. regexp: '^BLOCK_REGISTRY=.*$'
  111. line: "BLOCK_REGISTRY='{{ lookup('oo_option', 'docker_blocked_registries') | oo_split()
  112. | oo_prepend_strings_in_list('--block-registry ') | join(' ') }}'"
  113. when: docker_check.stat.isreg and
  114. lookup('oo_option', 'docker_blocked_registries') != ''
  115. notify:
  116. - restart docker
  117. - name: Grant access to additional insecure registries
  118. lineinfile:
  119. dest: /etc/sysconfig/docker
  120. regexp: '^INSECURE_REGISTRY=.*'
  121. line: "INSECURE_REGISTRY='{{ lookup('oo_option', 'docker_insecure_registries') | oo_split()
  122. | oo_prepend_strings_in_list('--insecure-registry ') | join(' ') }}'"
  123. when: docker_check.stat.isreg and
  124. lookup('oo_option', 'docker_insecure_registries') != ''
  125. notify:
  126. - restart docker
  127. - name: Additional storage plugin configuration
  128. include: storage_plugins/main.yml
  129. - name: Start and enable node
  130. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  131. register: start_result
  132. - set_fact:
  133. node_service_status_changed = start_result | changed