main.yml 4.6 KB

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