main.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. # Necessary because when you're on a node that's also a master the master will be
  3. # restarted after the node restarts docker and it will take up to 60 seconds for
  4. # systemd to start the master again
  5. - name: Wait for master API to become available before proceeding
  6. # Using curl here since the uri module requires python-httplib2 and
  7. # wait_for port doesn't provide health information.
  8. command: >
  9. curl --silent --tlsv1.2
  10. {% if openshift.common.version_gte_3_2_or_1_2 | bool %}
  11. --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
  12. {% else %}
  13. --cacert {{ openshift.common.config_base }}/master/ca.crt
  14. {% endif %}
  15. {{ openshift_node_master_api_url }}/healthz/ready
  16. args:
  17. # Disables the following warning:
  18. # Consider using get_url or uri module rather than running curl
  19. warn: no
  20. register: api_available_output
  21. until: api_available_output.stdout == 'ok'
  22. retries: 120
  23. delay: 1
  24. changed_when: false
  25. when: openshift.common.is_containerized | bool
  26. delegate_to: "{{ openshift_master_host }}"
  27. run_once: true
  28. - name: Wait for Node Registration
  29. oc_obj:
  30. name: "{{ openshift.node.nodename }}"
  31. kind: node
  32. state: list
  33. kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
  34. register: get_node
  35. until: "'metadata' in get_node.results.results[0]"
  36. retries: 50
  37. delay: 5
  38. when: "'nodename' in openshift.node"
  39. delegate_to: "{{ openshift_master_host }}"
  40. - name: Set node schedulability
  41. oadm_manage_node:
  42. node: "{{ openshift.node.nodename | lower }}"
  43. schedulable: "{{ 'true' if openshift.node.schedulable | bool else 'false' }}"
  44. kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
  45. retries: 10
  46. delay: 5
  47. register: node_schedulable
  48. until: node_schedulable|succeeded
  49. when: "'nodename' in openshift.node"
  50. delegate_to: "{{ openshift_master_host }}"
  51. - name: Label nodes
  52. oc_label:
  53. name: "{{ openshift.node.nodename }}"
  54. kind: node
  55. state: add
  56. labels: "{{ openshift.node.labels | oo_dict_to_list_of_dict }}"
  57. kubeconfig: "{{ openshift.common.config_base }}/master/admin.kubeconfig"
  58. namespace: default
  59. when:
  60. - "'nodename' in openshift.node"
  61. - "'labels' in openshift.node"
  62. - openshift.node.labels != {}
  63. delegate_to: "{{ openshift_master_host }}"