config.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. - name: Install the systemd units
  3. include_tasks: systemd_units.yml
  4. - name: Pull container images
  5. include_tasks: container_images.yml
  6. when: openshift_is_containerized | bool
  7. - name: Start and enable openvswitch service
  8. systemd:
  9. name: openvswitch.service
  10. enabled: yes
  11. state: started
  12. daemon_reload: yes
  13. when:
  14. - openshift_is_containerized | bool
  15. - openshift_node_use_openshift_sdn | default(true) | bool
  16. register: ovs_start_result
  17. until: not (ovs_start_result is failed)
  18. retries: 3
  19. delay: 30
  20. - set_fact:
  21. ovs_service_status_changed: "{{ ovs_start_result is changed }}"
  22. - file:
  23. dest: "{{ l2_openshift_node_kubelet_args['config'] }}"
  24. state: directory
  25. when: ('config' in l2_openshift_node_kubelet_args) | bool
  26. # TODO: add the validate parameter when there is a validation command to run
  27. - name: Create the Node config
  28. template:
  29. dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
  30. src: node.yaml.v1.j2
  31. backup: true
  32. owner: root
  33. group: root
  34. mode: 0600
  35. notify:
  36. - restart node
  37. - name: Configure Node Environment Variables
  38. lineinfile:
  39. dest: /etc/sysconfig/{{ openshift_service_type }}-node
  40. regexp: "^{{ item.key }}="
  41. line: "{{ item.key }}={{ item.value }}"
  42. create: true
  43. with_dict: "{{ openshift_node_env_vars }}"
  44. notify:
  45. - restart node
  46. - name: Ensure the node static pod directory exists
  47. file:
  48. path: "{{ openshift.common.config_base }}/node/pods"
  49. state: directory
  50. mode: 0755
  51. - name: include aws provider credentials
  52. import_tasks: aws.yml
  53. when: not (openshift_node_use_instance_profiles | default(False))
  54. # Necessary because when you're on a node that's also a master the master will be
  55. # restarted after the node restarts docker and it will take up to 60 seconds for
  56. # systemd to start the master again
  57. - when:
  58. - openshift_is_containerized | bool
  59. - not openshift_node_bootstrap
  60. block:
  61. - name: Wait for master API to become available before proceeding
  62. # Using curl here since the uri module requires python-httplib2 and
  63. # wait_for port doesn't provide health information.
  64. command: >
  65. curl --silent --tlsv1.2 --cacert {{ openshift.common.config_base }}/node/ca.crt
  66. {{ openshift_node_master_api_url }}/healthz/ready
  67. args:
  68. # Disables the following warning:
  69. # Consider using get_url or uri module rather than running curl
  70. warn: no
  71. register: api_available_output
  72. until: api_available_output.stdout == 'ok'
  73. retries: 120
  74. delay: 1
  75. changed_when: false
  76. - name: Start and enable node dep
  77. systemd:
  78. daemon_reload: yes
  79. name: "{{ openshift_service_type }}-node-dep"
  80. enabled: yes
  81. state: started
  82. - when: not openshift_node_bootstrap
  83. block:
  84. - name: Start and enable node
  85. systemd:
  86. name: "{{ openshift_service_type }}-node"
  87. enabled: yes
  88. state: started
  89. daemon_reload: yes
  90. register: node_start_result
  91. until: not node_start_result is failed
  92. retries: 1
  93. delay: 30
  94. ignore_errors: true
  95. - name: Dump logs from node service if it failed
  96. command: journalctl --no-pager -n 100 -u {{ openshift_service_type }}-node
  97. when: node_start_result is failed
  98. - name: Abort if node failed to start
  99. fail:
  100. msg: Node failed to start please inspect the logs and try again
  101. when: node_start_result is failed
  102. - set_fact:
  103. node_service_status_changed: "{{ node_start_result is changed }}"