zuul-jobs/roles/collect-kubernetes-logs/tasks/main.yaml
Albin Vass d0e2016592 Add loop var policy to ansible-lint
This adds a custom ansible-lint rule at .rules/ZuulJobsNamespaceLoopVar.py
that enforces the loop var policy described at:
https://zuul-ci.org/docs/zuul-jobs/policy.html#ansible-loops-in-roles

It also updates existing roles to follow the policy.

Change-Id: I92b2ff56a1c2702542fc07b316f1809087a4c92f
2020-04-29 17:20:59 +02:00

43 lines
1.1 KiB
YAML
Executable File

- name: List pods
command: "kubectl get pod -o=custom-columns=NAME:.metadata.name --no-headers"
register: podlist
failed_when: false
- name: Create pod describe dir
file:
path: "{{ ansible_user_dir }}/zuul-output/logs/pods"
state: directory
- name: Save pod descriptions
loop: "{{ podlist.stdout_lines | default([]) }}"
loop_control:
loop_var: zj_pod_name
shell: "kubectl describe po {{ zj_pod_name }} &> {{ ansible_user_dir }}/zuul-output/logs/pods/{{ zj_pod_name }}.txt"
args:
executable: /bin/bash
failed_when: false
- name: Open pod descriptions permissions
file:
dest: "{{ ansible_user_dir }}/zuul-output/logs/pods"
mode: u=rwX,g=rX,o=rX
recurse: yes
- name: Create kubelet log dir
file:
path: "{{ ansible_user_dir }}/zuul-output/logs/kubelet"
state: directory
- name: Save kubelet logs
shell: "journalctl -u kubelet &> {{ ansible_user_dir }}/zuul-output/logs/kubelet/kubelet.txt"
args:
executable: /bin/bash
failed_when: false
become: yes
- name: Open kubelet logs permissions
file:
dest: "{{ ansible_user_dir }}/zuul-output/logs/kubelet"
mode: u=rwX,g=rX,o=rX
recurse: yes