# win\_disk\_facts - get size and size remaining

**URL:** <https://forum.ansible.com/t/win-disk-facts-get-size-and-size-remaining/27504>\
**Category:** Ansible Project\
**Created:** [May 10, 2018, 11:22am UTC](https://forum.ansible.com/t/win-disk-facts-get-size-and-size-remaining/27504 "2018-05-10T11:22:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [May 10, 2018, 11:22am UTC](https://forum.ansible.com/t/win-disk-facts-get-size-and-size-remaining/27504/1 "2018-05-10T11:22:46Z")

</div>

Hi  
I’m trying to use win\_disk\_facts new module.

I would like to get the size and remaining size of each disk/partition/volume.

Is there a way to “discover” how many of them there are in a kind of loop ?

- name: Get disk facts  
win\_disk\_facts:
- name: Output first disk size  
debug:  
msg: ‘{{ disk1s }}’  
vars:  
disk1s: ‘{{ ansible\_facts.disks[0].partitions[0].volumes[0].size }}’

This one gives me info on the first partition, what about the others ? if there is 1 or 20 ?

Thanks!

@marqelme

@jborean93

---

<div class="post-metadata">

**Author:** ![Varun\_Chopra](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@Varun\_Chopra](https://forum.ansible.com/u/Varun_Chopra)\
**Post date:** [May 11, 2018, 4:29am UTC](https://forum.ansible.com/t/win-disk-facts-get-size-and-size-remaining/27504/2 "2018-05-11T04:29:28Z")

</div>

This is pretty much why I was in favor of a separate module for volumes. I’d encountered the same issues but I ended up making my own module for it. You can take a look at this if it suits your fancy: [https://github.com/chopraaa/win\_volume\_facts/](https://github.com/chopraaa/win_volume_facts/)

It’s kinda shit tbh but hey, it does the job.

---

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [May 15, 2018, 5:52am UTC](https://forum.ansible.com/t/win-disk-facts-get-size-and-size-remaining/27504/3 "2018-05-15T05:52:52Z")

</div>

I found how to loop over the data, but i still didn’t figure out how to select inside specific data

- name: test 1  
debug:  
msg: “{{ item.key }}”  
with\_dict: “{{ ansible\_disks }}”

Got:

`

…  
ok: [hostname] =\> (item=None) =\> {  
“msg”: “partitions”  
}  
…

`

If trying to dig into partitions

{{ item.value.partitions }}

`"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'partitions'`

Any chance someone give an input, it seems just a json gap i have and not ansible actually.

Thanks!
