main.yml 5.3 KB

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