main.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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']
  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. labels: "{{ openshift_node_labels | default(none) }}"
  25. annotations: "{{ openshift_node_annotations | default(none) }}"
  26. registry_url: "{{ oreg_url | default(none) }}"
  27. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  28. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  29. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  30. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  31. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  32. # problems because the rpms don't pin the version properly.
  33. - name: Install Node package
  34. yum: pkg={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present
  35. register: node_install_result
  36. - name: Install sdn-ovs package
  37. yum: pkg={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present
  38. register: sdn_install_result
  39. when: openshift.common.use_openshift_sdn
  40. # TODO: add the validate parameter when there is a validation command to run
  41. - name: Create the Node config
  42. template:
  43. dest: "{{ openshift_node_config_file }}"
  44. src: node.yaml.v1.j2
  45. notify:
  46. - restart node
  47. - name: Configure Node settings
  48. lineinfile:
  49. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  50. regexp: "{{ item.regex }}"
  51. line: "{{ item.line }}"
  52. with_items:
  53. - regex: '^OPTIONS='
  54. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  55. - regex: '^CONFIG_FILE='
  56. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  57. notify:
  58. - restart node
  59. - stat: path=/etc/sysconfig/docker
  60. register: docker_check
  61. # TODO: Enable secure registry when code available in origin
  62. - name: Secure Registry
  63. lineinfile:
  64. dest: /etc/sysconfig/docker
  65. regexp: '^OPTIONS=.*$'
  66. line: "OPTIONS='--insecure-registry={{ openshift.node.portal_net }} \
  67. {% if ansible_selinux and ansible_selinux.status == '''enabled''' %}--selinux-enabled{% endif %}'"
  68. when: docker_check.stat.isreg
  69. notify:
  70. - restart docker
  71. - set_fact:
  72. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  73. | oo_split() | union(['registry.access.redhat.com'])
  74. | difference(['']) }}"
  75. when: openshift.common.deployment_type == 'enterprise'
  76. - set_fact:
  77. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  78. | oo_split() | difference(['']) }}"
  79. when: openshift.common.deployment_type != 'enterprise'
  80. - name: Add personal registries
  81. lineinfile:
  82. dest: /etc/sysconfig/docker
  83. regexp: '^ADD_REGISTRY=.*$'
  84. line: "ADD_REGISTRY='{{ docker_additional_registries
  85. | oo_prepend_strings_in_list('--add-registry ') | join(' ') }}'"
  86. when: docker_check.stat.isreg and docker_additional_registries
  87. notify:
  88. - restart docker
  89. - name: Block registries
  90. lineinfile:
  91. dest: /etc/sysconfig/docker
  92. regexp: '^BLOCK_REGISTRY=.*$'
  93. line: "BLOCK_REGISTRY='{{ lookup('oo_option', 'docker_blocked_registries') | oo_split()
  94. | oo_prepend_strings_in_list('--block-registry ') | join(' ') }}'"
  95. when: docker_check.stat.isreg and
  96. lookup('oo_option', 'docker_blocked_registries') != ''
  97. notify:
  98. - restart docker
  99. - name: Grant access to additional insecure registries
  100. lineinfile:
  101. dest: /etc/sysconfig/docker
  102. regexp: '^INSECURE_REGISTRY=.*'
  103. line: "INSECURE_REGISTRY='{{ lookup('oo_option', 'docker_insecure_registries') | oo_split()
  104. | oo_prepend_strings_in_list('--insecure-registry ') | join(' ') }}'"
  105. when: docker_check.stat.isreg and
  106. lookup('oo_option', 'docker_insecure_registries') != ''
  107. notify:
  108. - restart docker
  109. - name: Allow NFS access for VMs
  110. seboolean: name=virt_use_nfs state=yes persistent=yes
  111. when: ansible_selinux and ansible_selinux.status == "enabled"
  112. - name: Start and enable node
  113. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  114. register: start_result
  115. - name: pause to prevent service restart from interfering with bootstrapping
  116. pause: seconds=30
  117. when: start_result | changed