# accessing nested facts

**URL:** <https://forum.ansible.com/t/accessing-nested-facts/29492>\
**Category:** Ansible Project\
**Created:** [January 22, 2019, 2:42pm UTC](https://forum.ansible.com/t/accessing-nested-facts/29492 "2019-01-22T14:42:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.tremel](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@christian.tremel](https://forum.ansible.com/u/christian.tremel)\
**Post date:** [January 22, 2019, 2:42pm UTC](https://forum.ansible.com/t/accessing-nested-facts/29492/1 "2019-01-22T14:42:21Z")

</div>

i have to follwing fact structure…how to access the “size\_available” stuff from the opt filesystem?

i tried this but it looks dorky…

```auto
- name: check free space on /opt
  aix_filesystem:
                filesystem: /opt
                size: +1G 
                state: present
  when: ansible_facts["mounts"]["mount"] == "/opt" and
        ansible_facts["mounts"]["size_available"] < 1073741824 

there should be a "one line" solution imho.

```

“mounts”: [

| 

{

 |
|
| |

| 

“device”: “/dev/hd4”,

 |
|
| |

| 

“fstype”: “jfs2”,

 |
|
| |

| 

“mount”: “/opt”,

 |
|
| |

| 

“options”: “rw,log=/dev/hd8”,

 |
|
| |

| 

“size\_available”: 92508160,

 |
|
| |

| 

“size\_total”: 134217728,

 |
|
| |

| 

“time”: “May 05 14:39”

 |
|
| |

| 

}

 |
|
| |

| |
|
| |

| 

];

 |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

| |
|
| |

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 22, 2019, 8:33pm UTC](https://forum.ansible.com/t/accessing-nested-facts/29492/2 "2019-01-22T20:33:32Z")

</div>

Your mount is a list so you need to specify the element 0 for them both

ansible\_facts["mounts"][0]["mount"]  
ansible\_facts["mounts"][0]["size\_available"]
