-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path09_get_pod_status.yaml
More file actions
36 lines (31 loc) · 845 Bytes
/
09_get_pod_status.yaml
File metadata and controls
36 lines (31 loc) · 845 Bytes
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
---
- name: Get pod status in a namespace
hosts: localhost
connection: local
gather_facts: false
vars:
kubeconfig_path: "/root/ocp4/auth/kubeconfig"
namespace: "default" # change as needed
tasks:
- name: Ensure required Python packages are installed
pip:
name:
- openshift
- kubernetes
state: present
- name: Get all pods in the namespace
k8s_info:
kubeconfig: "{{ kubeconfig_path }}"
kind: Pod
namespace: "{{ namespace }}"
register: pod_info
- name: Show pod names and statuses
debug:
msg: >-
{{
pod_info.resources
| map(attribute='metadata.name')
| zip(pod_info.resources | map(attribute='status.phase'))
| map('join', ': ')
| list
}}