# Ansible register stdout\_lines

**URL:** <https://forum.ansible.com/t/ansible-register-stdout-lines/37479>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [December 19, 2022, 8:10am UTC](https://forum.ansible.com/t/ansible-register-stdout-lines/37479 "2022-12-19T08:10:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepanshu\_Dang1](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Deepanshu\_Dang1](https://forum.ansible.com/u/Deepanshu_Dang1)\
**Post date:** [December 19, 2022, 8:10am UTC](https://forum.ansible.com/t/ansible-register-stdout-lines/37479/1 "2022-12-19T08:10:12Z")

</div>

Hi team

Need your support I’m looking out for put loop on register stdout \_lines  
my stdout\_lines output is this

“stdout\_lines”: [  
“NAME READY STATUS RESTARTS AGE”,  
“kafka-0 1/1 Running 3 (3h1m ago) 3d”,  
“kafka-1 1/1 Running 3 (3h1m ago) 3d”,  
“kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d”  
]

My playbook task is this

- name: List of {{release\_name}} pods  
shell: kubectl get pods -l ‘[app.kubernetes.io/component](http://app.kubernetes.io/component) in (zookeeper,kafka)’  
register: pod\_output  
when: pod\_status is succeeded
- debug:  
var: pod\_output.stdout\_lines

Output:

“pod\_output”: {  
“changed”: true,  
“cmd”: “kubectl get pods -l ‘[app.kubernetes.io/component](http://app.kubernetes.io/component) in (zookeeper,kafka)’”,  
“delta”: “0:00:00.080215”,  
“end”: “2022-12-19 07:35:22.925000”,  
“failed”: false,  
“rc”: 0,  
“start”: “2022-12-19 07:35:22.844785”,  
“stderr”: “”,  
“stderr\_lines”: ,  
“stdout”: “NAME READY STATUS RESTARTS AGE\nkafka-0 1/1 Running 3 (3h1m ago) 3d\nkafka-1 1/1 Running 3 (3h1m ago) 3d\nkafka-zookeeper-  
0 1/1 Running 1 (3h2m ago) 3d”,  
“stdout\_lines”: [  
“NAME READY STATUS RESTARTS AGE”,  
“kafka-0 1/1 Running 3 (3h1m ago) 3d”,  
“kafka-1 1/1 Running 3 (3h1m ago) 3d”,  
“kafka-zookeeper-0 1/1 Running 1 (3h2m ago) 3d”  
]  
}  
}

Now i want to put loop or with\_items on the stdout\_lines to check the status of running if it is not running i will get a result

How can i achieve this with the help of loop or with\_items.  
Stdout\_lines are list but when i’m trying it it showing me {“msg”: “‘dict object’ has no attribute ‘stdout’”}

How can I achieve this can you please help me

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [December 19, 2022, 8:59am UTC](https://forum.ansible.com/t/ansible-register-stdout-lines/37479/2 "2022-12-19T08:59:14Z")

</div>

Hii

You're trying to parse the standard format, which is not meant to be parsed.  
Instead use the json output option of kubectl.
