alerts-start.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: Ensure siege is on workstation
  27. become: yes
  28. package:
  29. name: siege
  30. state: latest
  31. - name: Check whether the namespace is already there
  32. k8s_info:
  33. kubeconfig: tmp/kubeconfig-ocp4
  34. validate_certs: no
  35. api_version: v1
  36. kind: namespace
  37. name: "{{ ge_nsp }}"
  38. register: ge_exists
  39. - name: Fail if the namespace exists
  40. fail:
  41. msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
  42. when: ge_exists.resources | length > 0
  43. - name: Ensure there is a namespace for the exercise
  44. k8s:
  45. kubeconfig: tmp/kubeconfig-ocp4
  46. validate_certs: no
  47. api_version: v1
  48. kind: namespace
  49. name: "{{ ge_nsp }}"
  50. - name: Give developer admin role in the project
  51. k8s:
  52. kubeconfig: tmp/kubeconfig-ocp4
  53. validate_certs: no
  54. api_version: rbac.authorization.k8s.io/v1
  55. kind: rolebinding
  56. namespace: "{{ ge_nsp }}"
  57. name: dev-admin
  58. definition:
  59. roleRef:
  60. apiGroup: rbac.authorization.k8s.io
  61. kind: ClusterRole
  62. name: admin
  63. subjects:
  64. - apiGroup: rbac.authorization.k8s.io
  65. kind: User
  66. name: developer
  67. - name: Deploy the sample app manifests
  68. k8s:
  69. kubeconfig: tmp/kubeconfig-ocp4
  70. validate_certs: no
  71. namespace: "{{ ge_nsp }}"
  72. src: ../labs/monitoring/alerts/{{ item }}
  73. loop:
  74. - frontend.yaml
  75. - exoplanets.yaml
  76. ...