main.yml 5.3 KB

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