main.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Create temp directory for kubeconfig
  3. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  4. register: mktemp
  5. changed_when: False
  6. - set_fact:
  7. openshift_manage_node_kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
  8. - name: Copy the admin client config(s)
  9. command: >
  10. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ openshift_manage_node_kubeconfig }}
  11. changed_when: False
  12. - name: Wait for Node Registration
  13. command: >
  14. {{ openshift.common.client_binary }} get node {{ hostvars[item].openshift.node.nodename }}
  15. --config={{ openshift_manage_node_kubeconfig }}
  16. -n default
  17. register: omd_get_node
  18. until: omd_get_node.rc == 0
  19. retries: 50
  20. delay: 5
  21. changed_when: false
  22. with_items: "{{ openshift_nodes }}"
  23. - name: Set node schedulability
  24. command: >
  25. {{ openshift.common.client_binary }} adm manage-node {{ hostvars[item].openshift.node.nodename }} --schedulable={{ 'true' if hostvars[item].openshift.node.schedulable | bool else 'false' }}
  26. --config={{ openshift_manage_node_kubeconfig }}
  27. -n default
  28. with_items: "{{ openshift_nodes }}"
  29. when: hostvars[item].openshift.node.nodename is defined
  30. - name: Label nodes
  31. command: >
  32. {{ openshift.common.client_binary }} label --overwrite node {{ hostvars[item].openshift.node.nodename }} {{ hostvars[item].openshift.node.labels | oo_combine_dict }}
  33. --config={{ openshift_manage_node_kubeconfig }}
  34. -n default
  35. with_items: "{{ openshift_nodes }}"
  36. when: hostvars[item].openshift.node.nodename is defined and 'labels' in hostvars[item].openshift.node and hostvars[item].openshift.node.labels != {}
  37. - name: Delete temp directory
  38. file:
  39. name: "{{ mktemp.stdout }}"
  40. state: absent
  41. changed_when: False