main.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ---
  2. # TODO: allow for overriding default ports where possible
  3. - fail:
  4. msg: "SELinux is disabled, This deployment type requires that SELinux is enabled."
  5. when: (not ansible_selinux or ansible_selinux.status != 'enabled') and deployment_type in ['enterprise', 'online', 'atomic-enterprise', 'openshift-enterprise']
  6. - fail:
  7. msg: "This playbook does not support using SDN on atomic hosts yet"
  8. when: openshift.common.use_openshift_sdn and is_atomic
  9. - name: Set node facts
  10. openshift_facts:
  11. role: "{{ item.role }}"
  12. local_facts: "{{ item.local_facts }}"
  13. with_items:
  14. - role: common
  15. local_facts:
  16. hostname: "{{ openshift_hostname | default(none) }}"
  17. public_hostname: "{{ openshift_public_hostname | default(none) }}"
  18. deployment_type: "{{ openshift_deployment_type }}"
  19. # TODO: Replace this with a lookup or filter plugin.
  20. dns_ip: "{{ openshift_dns_ip
  21. | default(openshift_master_cluster_vip
  22. | default(None if openshift.common.version_greater_than_3_1_or_1_1 | bool else openshift_node_first_master_ip | default(None, true), true), true) }}"
  23. - role: node
  24. local_facts:
  25. annotations: "{{ openshift_node_annotations | default(none) }}"
  26. debug_level: "{{ openshift_node_debug_level | default(openshift.common.debug_level) }}"
  27. docker_log_driver: "{{ lookup( 'oo_option' , 'docker_log_driver' ) | default('',True) }}"
  28. docker_log_options: "{{ lookup( 'oo_option' , 'docker_log_options' ) | default('',True) }}"
  29. iptables_sync_period: "{{ openshift_node_iptables_sync_period | default(None) }}"
  30. kubelet_args: "{{ openshift_node_kubelet_args | default(None) }}"
  31. labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"
  32. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  33. registry_url: "{{ oreg_url | default(none) }}"
  34. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  35. sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
  36. storage_plugin_deps: "{{ osn_storage_plugin_deps | default(None) }}"
  37. set_node_ip: "{{ openshift_set_node_ip | default(None) }}"
  38. # We have to add tuned-profiles in the same transaction otherwise we run into depsolving
  39. # problems because the rpms don't pin the version properly.
  40. - name: Install Node package
  41. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version }} state=present"
  42. when: not is_atomic
  43. - name: Install sdn-ovs package
  44. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }} state=present"
  45. when: openshift.common.use_openshift_sdn and not is_atomic
  46. # TODO: add the validate parameter when there is a validation command to run
  47. - name: Create the Node config
  48. template:
  49. dest: "{{ openshift_node_config_file }}"
  50. src: node.yaml.v1.j2
  51. backup: true
  52. notify:
  53. - restart node
  54. - name: Configure Node settings
  55. lineinfile:
  56. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  57. regexp: "{{ item.regex }}"
  58. line: "{{ item.line }}"
  59. create: true
  60. with_items:
  61. - regex: '^OPTIONS='
  62. line: "OPTIONS=--loglevel={{ openshift.node.debug_level }}"
  63. - regex: '^CONFIG_FILE='
  64. line: "CONFIG_FILE={{ openshift_node_config_file }}"
  65. notify:
  66. - restart node
  67. - stat: path=/etc/sysconfig/docker
  68. register: docker_check
  69. # TODO: Enable secure registry when code available in origin
  70. - name: Secure Registry and Logs Options
  71. lineinfile:
  72. dest: /etc/sysconfig/docker
  73. regexp: '^OPTIONS=.*$'
  74. line: "OPTIONS='--insecure-registry={{ openshift.node.portal_net }} \
  75. {% if ansible_selinux and ansible_selinux.status == '''enabled''' %}--selinux-enabled{% endif %} \
  76. {% if openshift.node.docker_log_driver is defined %} --log-driver {{ openshift.node.docker_log_driver }} {% endif %} \
  77. {% if openshift.node.docker_log_options is defined %} {{ openshift.node.docker_log_options | oo_split() | oo_prepend_strings_in_list('--log-opt ') | join(' ')}} {% endif %} '"
  78. when: docker_check.stat.isreg
  79. notify:
  80. - restart docker
  81. - set_fact:
  82. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  83. | oo_split() | union(['registry.access.redhat.com'])
  84. | difference(['']) }}"
  85. when: openshift.common.deployment_type in ['enterprise', 'openshift-enterprise', 'atomic-enterprise']
  86. - set_fact:
  87. docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries')
  88. | oo_split() | difference(['']) }}"
  89. when: openshift.common.deployment_type not in ['enterprise', 'openshift-enterprise', 'atomic-enterprise']
  90. - name: Add personal registries
  91. lineinfile:
  92. dest: /etc/sysconfig/docker
  93. regexp: '^ADD_REGISTRY=.*$'
  94. line: "ADD_REGISTRY='{{ docker_additional_registries
  95. | oo_prepend_strings_in_list('--add-registry ') | join(' ') }}'"
  96. when: docker_check.stat.isreg and docker_additional_registries
  97. notify:
  98. - restart docker
  99. - name: Block registries
  100. lineinfile:
  101. dest: /etc/sysconfig/docker
  102. regexp: '^BLOCK_REGISTRY=.*$'
  103. line: "BLOCK_REGISTRY='{{ lookup('oo_option', 'docker_blocked_registries') | oo_split()
  104. | oo_prepend_strings_in_list('--block-registry ') | join(' ') }}'"
  105. when: docker_check.stat.isreg and
  106. lookup('oo_option', 'docker_blocked_registries') != ''
  107. notify:
  108. - restart docker
  109. - name: Grant access to additional insecure registries
  110. lineinfile:
  111. dest: /etc/sysconfig/docker
  112. regexp: '^INSECURE_REGISTRY=.*'
  113. line: "INSECURE_REGISTRY='{{ lookup('oo_option', 'docker_insecure_registries') | oo_split()
  114. | oo_prepend_strings_in_list('--insecure-registry ') | join(' ') }}'"
  115. when: docker_check.stat.isreg and
  116. lookup('oo_option', 'docker_insecure_registries') != ''
  117. notify:
  118. - restart docker
  119. - name: Additional storage plugin configuration
  120. include: storage_plugins/main.yml
  121. - name: Start and enable node
  122. service: name={{ openshift.common.service_type }}-node enabled=yes state=started
  123. register: start_result
  124. - set_fact:
  125. node_service_status_changed: start_result | changed