config.yml 2.9 KB

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