ironic/playbooks/metal3-ci/fetch_pod_logs.yaml
Dmitry Tantsur a6d87a608c Add a non-voting metal3 CI job
We'll use only one node as we're limited in resources but that
should suffice for a basic test.

Change-Id: I8e845d46ba0e13027aa1e628b0ad45eb24f9b387
2023-03-06 12:16:27 +01:00

25 lines
810 B
YAML

---
- name: Create the target directory
file:
path: "{{ logs_management_cluster }}/{{ namespace }}/{{ pod }}"
state: directory
- name: Fetch pod information
command: kubectl get pod -n "{{ namespace }}" -o json "{{ pod }}"
register: pod_result
- name: Process pod JSON
set_fact:
pod_json: "{{ pod_result.stdout | from_json }}"
- name: Set container names
set_fact:
containers: "{{ pod_json.spec.containers | map(attribute='name') | list }}"
init_containers: "{{ pod_json.spec.initContainers | default([]) | map(attribute='name') | list }}"
- name: Fetch container logs
shell: |
kubectl logs -n "{{ namespace }}" "{{ pod }}" "{{ item }}" \
> "{{ logs_management_cluster }}/{{ namespace }}/{{ pod }}/{{ item }}.log" 2>&1
loop: "{{ containers + init_containers }}"