navigate-start.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ---
  2. - name: Prepare for the navigate exercise
  3. hosts: workstation.lab.example.com
  4. gather_subset: min
  5. become: no
  6. vars:
  7. ge_nsp: deploy-introduction
  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: Give developer admin role in the project
  46. k8s:
  47. kubeconfig: tmp/kubeconfig-ocp4
  48. validate_certs: no
  49. api_version: rbac.authorization.k8s.io/v1
  50. kind: rolebinding
  51. namespace: "{{ ge_nsp }}"
  52. name: dev-admin
  53. definition:
  54. roleRef:
  55. apiGroup: rbac.authorization.k8s.io
  56. kind: ClusterRole
  57. name: admin
  58. subjects:
  59. - apiGroup: rbac.authorization.k8s.io
  60. kind: User
  61. name: developer
  62. - name: Deploy the sample app manifest
  63. k8s:
  64. kubeconfig: tmp/kubeconfig-ocp4
  65. validate_certs: no
  66. namespace: "{{ ge_nsp }}"
  67. src: ../labs/health/navigate/sample-node-app.yaml