main.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ---
  2. - name: Create temp directory for kubeconfig
  3. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  4. register: mktemp
  5. changed_when: False
  6. delegate_to: "{{ openshift_master_host }}"
  7. run_once: true
  8. - set_fact:
  9. openshift_manage_node_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  10. delegate_to: "{{ openshift_master_host }}"
  11. run_once: true
  12. - name: Copy the admin client config(s)
  13. command: >
  14. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ openshift_manage_node_kubeconfig }}
  15. changed_when: False
  16. delegate_to: "{{ openshift_master_host }}"
  17. run_once: true
  18. # Necessary because when you're on a node that's also a master the master will be
  19. # restarted after the node restarts docker and it will take up to 60 seconds for
  20. # systemd to start the master again
  21. - name: Wait for master API to become available before proceeding
  22. # Using curl here since the uri module requires python-httplib2 and
  23. # wait_for port doesn't provide health information.
  24. command: >
  25. curl --silent --tlsv1.2
  26. {% if openshift.common.version_gte_3_2_or_1_2 | bool %}
  27. --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
  28. {% else %}
  29. --cacert {{ openshift.common.config_base }}/master/ca.crt
  30. {% endif %}
  31. {{ openshift_node_master_api_url }}/healthz/ready
  32. args:
  33. # Disables the following warning:
  34. # Consider using get_url or uri module rather than running curl
  35. warn: no
  36. register: api_available_output
  37. until: api_available_output.stdout == 'ok'
  38. retries: 120
  39. delay: 1
  40. changed_when: false
  41. when: openshift.common.is_containerized | bool
  42. delegate_to: "{{ openshift_master_host }}"
  43. run_once: true
  44. - name: Wait for Node Registration
  45. command: >
  46. {{ openshift.common.client_binary }} get node {{ openshift.node.nodename }}
  47. --config={{ openshift_manage_node_kubeconfig }}
  48. -n default
  49. register: omd_get_node
  50. until: omd_get_node.rc == 0
  51. retries: 50
  52. delay: 5
  53. changed_when: false
  54. when: "'nodename' in openshift.node"
  55. delegate_to: "{{ openshift_master_host }}"
  56. - name: Set node schedulability
  57. command: >
  58. {{ openshift.common.client_binary }} adm manage-node {{ openshift.node.nodename }} --schedulable={{ 'true' if openshift.node.schedulable | bool else 'false' }}
  59. --config={{ openshift_manage_node_kubeconfig }}
  60. -n default
  61. when: "'nodename' in openshift.node"
  62. delegate_to: "{{ openshift_master_host }}"
  63. - name: Label nodes
  64. command: >
  65. {{ openshift.common.client_binary }} label --overwrite node {{ openshift.node.nodename }} {{ openshift.node.labels | oo_combine_dict }}
  66. --config={{ openshift_manage_node_kubeconfig }}
  67. -n default
  68. when: "'nodename' in openshift.node and 'labels' in openshift.node and openshift.node.labels != {}"
  69. delegate_to: "{{ openshift_master_host }}"
  70. - name: Delete temp directory
  71. file:
  72. name: "{{ mktemp.stdout }}"
  73. state: absent
  74. changed_when: False
  75. delegate_to: "{{ openshift_master_host }}"
  76. run_once: true