alerts-start.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. - name: Deploy the sample app manifests
  46. k8s:
  47. kubeconfig: tmp/kubeconfig-ocp4
  48. validate_certs: no
  49. namespace: "{{ ge_nsp }}"
  50. src: ../labs/monitoring/alerts/{{ item }}
  51. loop:
  52. - frontend.yaml
  53. - exoplanets.yaml
  54. ...