monitoring-start.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. - name: Prepare for the navigate exercise
  2. hosts: workstation.lab.example.com
  3. gather_subset: min
  4. become: no
  5. vars:
  6. ge_nsp: monitoring-apps
  7. pre_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. roles:
  26. - role: deploy-logging
  27. post_tasks:
  28. - name: Check whether the namespace is already there
  29. k8s_info:
  30. kubeconfig: tmp/kubeconfig-ocp4
  31. validate_certs: no
  32. api_version: v1
  33. kind: namespace
  34. name: "{{ ge_nsp }}"
  35. register: ge_exists
  36. - name: Fail if the namespace exists
  37. fail:
  38. msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
  39. when: ge_exists.resources | length > 0
  40. - name: Ensure there is a namespace for the exercise
  41. k8s:
  42. kubeconfig: tmp/kubeconfig-ocp4
  43. validate_certs: no
  44. api_version: v1
  45. kind: namespace
  46. name: "{{ ge_nsp }}"
  47. ...