monitoring-start.yml 1.4 KB

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