-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprocessinfo.yaml
41 lines (41 loc) · 1.39 KB
/
processinfo.yaml
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
33
34
35
36
37
38
39
40
41
- hosts: openshift
tasks:
- name: Get pod containers
shell: oc get po -n {{ item }} -o json | jq -r '.items[] | select(.status.conditions[] | select(.type=="Ready" and .status=="True")) | .status.containerStatuses[].containerID' | cut -c 10- | tr '\n' ' '
register: containers
loop:
- mannequin-test
- "{{ control_plane }}"
- name: Set containers
set_fact:
container_ids: "{{ item.container_ids }}"
delegate_to: "{{ item.host }}"
delegate_facts: true
run_once: true
loop:
- host: "{{ groups['compute'][0] }}"
container_ids: "{{ containers.results[0].stdout }}"
- host: "{{ groups['openshift'][0] }}"
container_ids: "{{ containers.results[1].stdout }}"
- hosts: [ compute, openshift ]
tasks:
- name: Get process ids
shell: sudo docker inspect {{ container_ids }}
register: docker_inspect
- name: Filter pids
set_fact:
pids: "{{ docker_inspect.stdout | from_json | json_query('[].State.Pid') }}"
- name: Get process info
# Assuming that container pids are session leaders
shell: ps fu -s {{ pids | join(' -s ')}}
register: psinfo
- hosts: 127.0.0.1
connection: local
tasks:
- name: Store process info
copy:
content: "{{ hostvars[item]['psinfo']['stdout'] }}"
dest: "ps.{{ hostvars[item]['ansible_fqdn'] }}.txt"
loop:
- "{{ groups['compute'][0] }}"
- "{{ groups['openshift'][0]}}"