accessing nested facts

15 views
Skip to first unread message

christia...@itsv.at

unread,
Jan 22, 2019, 9:42:21 AM1/22/19
to Ansible Project


i have to follwing fact structure...how to access the "size_available" stuff from the opt filesystem?

i tried this but it looks dorky...

- 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"
}
];








Kai Stian Olstad

unread,
Jan 22, 2019, 3:33:43 PM1/22/19
to ansible...@googlegroups.com
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"]


--
Kai Stian Olstad


Reply all
Reply to author
Forward
0 new messages