# get stdout from a registered variable

**URL:** <https://forum.ansible.com/t/get-stdout-from-a-registered-variable/18181>\
**Category:** Ansible Project\
**Created:** [May 7, 2015, 9:01am UTC](https://forum.ansible.com/t/get-stdout-from-a-registered-variable/18181 "2015-05-07T09:01:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yariv\_Graf](https://avatars.discourse-cdn.com/v4/letter/y/5e9695/32.png) [@Yariv\_Graf](https://forum.ansible.com/u/Yariv_Graf)\
**Post date:** [May 7, 2015, 9:01am UTC](https://forum.ansible.com/t/get-stdout-from-a-registered-variable/18181/1 "2015-05-07T09:01:15Z")

</div>

Hi,  
I have this piece of yaml playbook:

- name: get read block device such /dev/sdX  
shell: “readlink -f /dev/disk/by-id/google-{{ item.block }}”  
with\_items: mounts  
register: device

- debug: var=device.results

Trying to get the read “sd” device from a symlink.

the output of device.results is:

ok: [ygtest] =\> {  
“var”: {  
“device.results”: [  
{  
“changed”: true,  
“cmd”: “readlink -f /dev/disk/by-id/google-local-ssd-0”,  
“delta”: “0:00:00.003578”,  
“end”: “2015-05-07 08:56:24.201753”,  
“invocation”: {  
“module\_args”: “readlink -f /dev/disk/by-id/google-local-ssd-0”,  
“module\_name”: “shell”  
},  
“item”: {  
“block”: “local-ssd-0”  
},  
“rc”: 0,  
“start”: “2015-05-07 08:56:24.198175”,  
“stderr”: “”,  
“stdout”: “/dev/sdb”,  
“stdout\_lines”: [  
“/dev/sdb”  
],  
“warnings”:   
}  
]  
}  
}

How can I access the “stdout” value? I need the output of “/dev/sdb”

Thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 7, 2015, 2:23pm UTC](https://forum.ansible.com/t/get-stdout-from-a-registered-variable/18181/2 "2015-05-07T14:23:58Z")

</div>

the issue is that with\_items always creates a result list, so you can  
access stdout of each item this way:

device.results[i].stdout

where i is the 0 based index of items, since you seem to have only 1  
mount this will be what you need:

device.results[0].stdout

---

<div class="post-metadata">

**Author:** ![Yariv\_Graf](https://avatars.discourse-cdn.com/v4/letter/y/5e9695/32.png) [@Yariv\_Graf](https://forum.ansible.com/u/Yariv_Graf)\
**Post date:** [May 7, 2015, 2:35pm UTC](https://forum.ansible.com/t/get-stdout-from-a-registered-variable/18181/3 "2015-05-07T14:35:37Z")

</div>

Thank you
