main.yml 5.0 KB

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