Procházet zdrojové kódy

name plays correctly

Grega Bremec před 7 měsíci
rodič
revize
4b4d9dd302

+ 37 - 0
playbooks/alerts-finish.yml

@@ -0,0 +1,37 @@
+---
+- name: Clean up after the alerting exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: monitoring-alerts
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Ensure the namespace for the exercise is gone
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+        state: absent
+...

+ 50 - 0
playbooks/alerts-start.yml

@@ -0,0 +1,50 @@
+---
+- name: Prepare for the alerting exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: monitoring-alerts
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Check whether the namespace is already there
+      k8s_info:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+      register: ge_exists
+
+    - name: Fail if the namespace exists
+      fail:
+        msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
+      when: ge_exists.resources | length > 0
+
+    - name: Ensure there is a namespace for the exercise
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+...

+ 1 - 1
playbooks/console-finish.yml

@@ -1,5 +1,5 @@
 ---
-- name: Clean up after the navigate exercise
+- name: Clean up after the console exercise
   hosts: workstation.lab.example.com
   gather_subset: min
   become: no

+ 37 - 0
playbooks/logging-finish.yml

@@ -0,0 +1,37 @@
+---
+- name: Clean up after the logging exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: logging-central
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Ensure the namespace for the exercise is gone
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+        state: absent
+...

+ 53 - 0
playbooks/logging-start.yml

@@ -0,0 +1,53 @@
+- name: Prepare for the logging exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: logging-central
+  pre_tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+  roles:
+    - role: deploy-logging
+
+#  post_tasks:
+#    - name: Check whether the namespace is already there
+#      k8s_info:
+#        kubeconfig: tmp/kubeconfig-ocp4
+#        validate_certs: no
+#        api_version: v1
+#        kind: namespace
+#        name: "{{ ge_nsp }}"
+#      register: ge_exists
+#
+#    - name: Fail if the namespace exists
+#      fail:
+#        msg: "The exercise namespace already exists: {{ ge_nsp }}; please run strategy-finish.yml to clean up first and then re-run this playbook."
+#      when: ge_exists.resources | length > 0
+#
+#    - name: Ensure there is a namespace for the exercise
+#      k8s:
+#        kubeconfig: tmp/kubeconfig-ocp4
+#        validate_certs: no
+#        api_version: v1
+#        kind: namespace
+#        name: "{{ ge_nsp }}"
+...

+ 37 - 0
playbooks/monitoring-finish.yml

@@ -0,0 +1,37 @@
+---
+- name: Clean up after the monitoring exercise
+  hosts: workstation.lab.example.com
+  gather_subset: min
+  become: no
+  vars:
+    ge_nsp: monitoring-apps
+  tasks:
+    - name: Make sure kubeconfig is there on utility
+      delegate_to: utility.lab.example.com
+      file:
+        path: /home/lab/{{ item }}/auth/kubeconfig
+        state: file
+      loop: "{{ clusters }}"
+
+    - name: Create a temp dir
+      file:
+        path: tmp
+        state: directory
+
+    - name: Copy over the kubeconfig
+      delegate_to: utility.lab.example.com
+      fetch:
+        src: /home/lab/{{ item }}/auth/kubeconfig
+        dest: tmp/kubeconfig-{{ item }}
+        flat: yes
+      loop: "{{ clusters }}"
+
+    - name: Ensure the namespace for the exercise is gone
+      k8s:
+        kubeconfig: tmp/kubeconfig-ocp4
+        validate_certs: no
+        api_version: v1
+        kind: namespace
+        name: "{{ ge_nsp }}"
+        state: absent
+...

+ 2 - 6
playbooks/monitoring-start.yml

@@ -1,10 +1,10 @@
-- name: Prepare for the navigate exercise
+- name: Prepare for the monitoring exercise
   hosts: workstation.lab.example.com
   gather_subset: min
   become: no
   vars:
     ge_nsp: monitoring-apps
-  pre_tasks:
+  tasks:
     - name: Make sure kubeconfig is there on utility
       delegate_to: utility.lab.example.com
       file:
@@ -25,10 +25,6 @@
         flat: yes
       loop: "{{ clusters }}"
 
-  roles:
-    - role: deploy-logging
-
-  post_tasks:
     - name: Check whether the namespace is already there
       k8s_info:
         kubeconfig: tmp/kubeconfig-ocp4

+ 1 - 1
playbooks/probes-start.yml

@@ -1,5 +1,5 @@
 ---
-- name: Prepare for the strategies exercise
+- name: Prepare for the probes exercise
   hosts: workstation.lab.example.com
   gather_subset: min
   become: no

+ 1 - 1
playbooks/stateful-finish.yml

@@ -1,5 +1,5 @@
 ---
-- name: Clean up after the strategies exercise
+- name: Clean up after the statefulset exercise
   hosts: workstation.lab.example.com
   gather_subset: min
   become: no

+ 1 - 1
playbooks/stateful-start.yml

@@ -1,5 +1,5 @@
 ---
-- name: Prepare for the strategies exercise
+- name: Prepare for the statefulset exercise
   hosts: workstation.lab.example.com
   gather_subset: min
   become: no