alerts-start.yml 1.4 KB

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