# Ansible debug msg  with item.stdout not working with Ansible 2.1

**URL:** <https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833>\
**Category:** Ansible Developer\
**Created:** [June 20, 2018, 6:03pm UTC](https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833 "2018-06-20T18:03:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rijesh\_Puthiya\_Puray](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@Rijesh\_Puthiya\_Puray](https://forum.ansible.com/u/Rijesh_Puthiya_Puray)\
**Post date:** [June 20, 2018, 6:03pm UTC](https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833/1 "2018-06-20T18:03:27Z")

</div>

Hello,

I have following playbook.

`

- hosts: localhost  
vars:  
routes:
- name: /blue
- name: /green  
password: test #will be reading from inventory in original case  
gather\_facts: no

tasks:

- name: Execute manage command  
shell: ./manage.sh “{{item.name}} {{password}}”  
with\_items:

- “{{routes}}”  
no\_log: true  
register: cmd\_out

- debug: msg=“item.rc={{item.rc}} item.stdout={{item.stdout}}”  
with\_items: “{{ cmd\_out.results }}”  
`

---

<div class="post-metadata">

**Author:** ![Abhijit\_Menon-Sen1](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Abhijit\_Menon-Sen1](https://forum.ansible.com/u/Abhijit_Menon-Sen1)\
**Post date:** [June 21, 2018, 6:34am UTC](https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833/2 "2018-06-21T06:34:56Z")

</div>

It is a waste of time to try to maintain compatibility between Ansible  
2.ancient and 2.recent. This is not the only problem you're going to  
run into, by far.

I suggest looking into shipping your customer a complete Python  
virtualenv containing a current version of Ansible as well as all  
dependencies. That way they can run your playbooks using a  
self-contained Ansible installation (i.e., restricted to a single  
directory), and the two Ansible installations will not interact in any  
way, so they don't need to upgrade anything, and it will not affect  
any other playbooks that they need to run under Ansible 2.1.

-- Abhijit

---

<div class="post-metadata">

**Author:** ![Rijesh\_Puthiya\_Puray](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@Rijesh\_Puthiya\_Puray](https://forum.ansible.com/u/Rijesh_Puthiya_Puray)\
**Post date:** [June 21, 2018, 8:46am UTC](https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833/3 "2018-06-21T08:46:59Z")

</div>

Hi Abhijit,

Agreed, but to tell you, its upgrade will take. We already initiated that effort but then its not straight forward considering amount of roles and plays they have and all of them needs to work well. Different version execution is also little difficult as the play orchestrated via UCD where UCD has its defined component process template. That’s the reason I am looking for a hack.

I just wanted to get a nice command output. I can get that by using

`

- debug: msg=“item.stdout={{cmd\_out.results[0].stdout}}”
- debug: msg=“item.stdout={{cmd\_out.results[1].stdout}}”

`

But then the problem is number of index can vary, so depends up on route items (based on number of items) I would be able to mark index.

If there is a quick way something like

`

- debug: msg="item.stdout=cmd\_out.results[index].stdout  
`

or with\_items would work.

Thanks  
Rijesh.

---

<div class="post-metadata">

**Author:** ![Rijesh\_Puthiya\_Puray](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@Rijesh\_Puthiya\_Puray](https://forum.ansible.com/u/Rijesh_Puthiya_Puray)\
**Post date:** [June 21, 2018, 12:00pm UTC](https://forum.ansible.com/t/ansible-debug-msg-with-item-stdout-not-working-with-ansible-2-1/27833/4 "2018-06-21T12:00:08Z")

</div>

No problem. I found a way to get this till Ansible getting updated.

`

# Assuming we support 5 routes, if this goes beyond, then it will fail. Long term solution is to get ansible upgraded and uncomment above block.

- debug: msg=“item.stdout={{cmd\_out\_set.results[0].stdout}}”  
when: cmd\_out\_set.results|length \> 0  
no\_log: false
- debug: msg=“item.stdout={{cmd\_out\_set.results[1].stdout}}”  
when: cmd\_out\_set.results|length \> 1  
no\_log: false
- debug: msg=“item.stdout={{cmd\_out\_set.results[2].stdout}}”  
when: cmd\_out\_set.results|length \> 2  
no\_log: false
- debug: msg=“item.stdout={{cmd\_out\_set.results[3].stdout}}”  
when: cmd\_out\_set.results|length \> 3  
no\_log: false
- debug: msg=“item.stdout={{cmd\_out\_set.results[4].stdout}}”  
when: cmd\_out\_set.results|length \> 4  
no\_log: false

`
