# i can't list hard disk info

**URL:** <https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243>\
**Category:** Ansible Project\
**Created:** [May 2, 2019, 7:02am UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243 "2019-05-02T07:02:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lander7500](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lander7500](https://forum.ansible.com/u/lander7500)\
**Post date:** [May 2, 2019, 7:02am UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243/1 "2019-05-02T07:02:57Z")

</div>

Hi, i use this playbook:

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [May 2, 2019, 11:14am UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243/2 "2019-05-02T11:14:17Z")

</div>

> Hi, i use this playbook:
> 
> ---  
> - hosts: host1  
> gather\_facts: false  
> connection: local
> 
> tasks:
> 
> - name: Gather disk facts from virtual machine using name  
> vmware\_guest\_disk\_facts:  
> # Unirse a vsphere  
> hostname: "{{ hostname }}"  
> username: "{{ username }}"  
> password: "{{ password }}"  
> datacenter: Datacenter  
> # Para pasar por el SSH sin autenticar nada  
> validate\_certs: no  
> # Nombre de la maquina  
> name: "{{vm}}"  
> delegate\_to: localhost  
> # Lo metemos en una variable  
> register: disk\_facts
> 
> - debug:  
> msg: "{{disk\_facts.guest\_disk\_facts}}"  
> ...
> 
> and the result is:
> 
> ok: [host1] =\> {  
> "msg": {  
> "0": {  
> "backing\_datastore": "datastore1",  
> "backing\_disk\_mode": "persistent",  
> "backing\_eagerlyscrub": false,  
> "backing\_filename": "[datastore1] ANSIBLE\_Centos/ANSIBLE\_Centos-000003.vmdk",  
> "backing\_thinprovisioned": false,  
> "backing\_writethrough": false,  
> "capacity\_in\_bytes": 17179869184,  
> "capacity\_in\_kb": 16777216,  
> "controller\_key": 1000,  
> "key": 2000,  
> "label": "Hard disk 1",  
> "summary": "16,777,216 KB",  
> "unit\_number": 0  
> },  
> "1": {  
> "backing\_datastore": "datastore1",  
> "backing\_disk\_mode": "persistent",  
> "backing\_eagerlyscrub": false,  
> "backing\_filename": "[datastore1] ANSIBLE\_Centos/ANSIBLE\_Centos\_3.vmdk",  
> "backing\_thinprovisioned": false,  
> "backing\_writethrough": false,  
> "capacity\_in\_bytes": 2147483648,  
> "capacity\_in\_kb": 2097152,  
> "controller\_key": 1000,  
> "key": 2001,  
> "label": "Hard disk 2",  
> "summary": "2,097,152 KB",  
> "unit\_number": 1  
> }  
> }  
> }
> 
> Good, i need second ("1") hard disk info, but when im use variable disk\_facts.guest\_disk\_facts.1 the result is:
> 
> fatal: [host1]: FAILED! =\> {"msg": "The task includes an option with an undefined variable. The error was: dict object has no element 1\n\nThe error appears to have been in '/root/playbook/operations/ListVMvalues.yml': line 50, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n"}
> 
> What I do?

Hi,

Try with disk\_facts.guest\_disk\_facts[1]instead...

Regards,

JYL

---

<div class="post-metadata">

**Author:** ![lander7500](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lander7500](https://forum.ansible.com/u/lander7500)\
**Post date:** [May 2, 2019, 11:17am UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243/3 "2019-05-02T11:17:51Z")

</div>

When i’m use disk\_facts.guest\_disk\_facts[1] the result is:

fatal: [host1]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: dict object has no element 1\n\nThe error appears to have been in ‘/root/playbook/operations/ListVMvalues.yml’: line 50, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n”}

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [May 2, 2019, 11:20am UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243/4 "2019-05-02T11:20:38Z")

</div>

> > and the result is:
> > 
> > ok: [host1] =\> {  
> > "msg": {  
> > "0": {  
> > "backing\_datastore": "datastore1",

[...]

> > },  
> > "1": {  
> > "backing\_datastore": "datastore1",

[...]

> > }  
> > }  
> > }
> > 
> > Good, i need second ("1") hard disk info, but when im use variable  
> > disk\_facts.guest\_disk\_facts.1 the result is:
> > 
> > fatal: [host1]: FAILED! =\> {"msg": "The task includes an option with  
> > an undefined variable. The error was: dict object has no element  
> > 1\n\nThe error appears to have been in  
> > '/root/playbook/operations/ListVMvalues.yml': line 50, column 7, but  
> > may\nbe elsewhere in the file depending on the exact syntax  
> > problem.\n\nThe offending line appears to be:\n\n\n - debug:\n  
> > ^ here\n"}
> > 
> > What I do?
> 
> Hi,
> 
> Try with disk\_facts.guest\_disk\_facts[1]instead...

disk\_facts.guest\_disk\_facts.1 and disk\_facts.guest\_disk\_facts[1]

both expect disk\_facts.guest\_disk\_facts to be a list, but it's a dict.

You'll need disk\_facts.guest\_disk\_facts['1']

Notice the ''.

Sebastian

---

<div class="post-metadata">

**Author:** ![lander7500](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lander7500](https://forum.ansible.com/u/lander7500)\
**Post date:** [May 2, 2019, 12:01pm UTC](https://forum.ansible.com/t/i-cant-list-hard-disk-info/30243/5 "2019-05-02T12:01:37Z")

</div>

oooooooooooh goooooooooood. THANK YOU VERY MUCH \<3
