strategy-start.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. - name: Prepare for the strategies exercise
  3. hosts: workstation.lab.example.com
  4. gather_subset: min
  5. become: no
  6. tasks:
  7. - name: Make sure kubeconfig is there on utility
  8. delegate_to: utility.lab.example.com
  9. file:
  10. path: /home/lab/{{ item }}/auth/kubeconfig
  11. state: file
  12. loop: "{{ clusters }}"
  13. - name: Create a temp dir
  14. file:
  15. path: tmp
  16. state: directory
  17. - name: Copy over the kubeconfig
  18. delegate_to: utility.lab.example.com
  19. fetch:
  20. src: /home/lab/{{ item }}/auth/kubeconfig
  21. dest: tmp/kubeconfig-{{ item }}
  22. flat: yes
  23. loop: "{{ clusters }}"
  24. - name: Check whether the namespace is already there
  25. k8s_info:
  26. kubeconfig: tmp/kubeconfig-ocp4
  27. validate_certs: no
  28. api_version: v1
  29. kind: namespace
  30. name: deployments-strategy
  31. register: ge_nsp
  32. - name: Fail if the namespace exists
  33. fail:
  34. msg: "The exercise namespace already exists: deployments-strategy; please run strategy-finish.yml to clean up first and then re-run this playbook."
  35. when: ge_nsp.resources | length > 0
  36. - name: Ensure there is a namespace for the exercise
  37. k8s:
  38. kubeconfig: tmp/kubeconfig-ocp4
  39. validate_certs: no
  40. api_version: v1
  41. kind: namespace
  42. name: deployments-strategy