main.yml 5.8 KB

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