summaryrefslogtreecommitdiff
path: root/playbooks/metal3-ci/fetch_kube_logs.yaml
blob: a202941783c5571135ca35a6cf048575fc4c1402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: Create the target directory
  file:
    path: "{{ logs_management_cluster }}/{{ namespace }}"
    state: directory

- name: Fetch pods list
  command: kubectl get pods -n "{{ namespace }}" -o json
  ignore_errors: true
  register: pods_result

- block:
    - name: Save the pods list
      copy:
        dest: "{{ logs_management_cluster }}/{{ namespace }}/pods.yaml"
        content: "{{ pods_result.stdout }}"

    - name: Set pod names
      set_fact:
        pods: "{{ pods_result.stdout | from_json | json_query('items[*].metadata.name') }}"

    - include_tasks: fetch_pod_logs.yaml
      loop: "{{ pods }}"
      loop_control:
        loop_var: pod
  when: pods_result is succeeded

- name: Fetch secrets
  shell: |
    kubectl get secrets -n "{{ namespace }}" -o yaml \
      > "{{ logs_management_cluster }}/{{ namespace }}/secrets.yaml"
  ignore_errors: true