-1

Im newbie when it comes to ansible started just a week ago. I was playing around with playbooks and ad-hoc command i run ad-hoc command ansible ansiblenodes -m setup -a "filter=ansible_mounts"

192.168.75.31 | SUCCESS => {
    "ansible_facts": {
        "ansible_mounts": [
            {
                "block_available": 217708,
                "block_size": 4096,
                "block_total": 259584,
                "block_used": 41876,
                "device": "/dev/sda1",
                "fstype": "xfs",
                "inode_available": 523952,
                "inode_total": 524288,
                "inode_used": 336,
                "mount": "/boot",
                "options": "rw,seclabel,relatime,attr2,inode64,noquota",
                "size_available": 891731968,
                "size_total": 1063256064,
                "uuid": "8a896a10-d8b0-4c95-9743-69b213b47f5a"
            },
            {
                "block_available": 2145829,
                "block_size": 4096,
                "block_total": 3273216,
                "block_used": 1127387,
                "device": "/dev/mapper/rhel-root",
                "fstype": "xfs",
                "inode_available": 6400742,
                "inode_total": 6551552,
                "inode_used": 150810,
                "mount": "/",
                "options": "rw,seclabel,relatime,attr2,inode64,noquota",
                "size_available": 8789315584,
                "size_total": 13407092736,
                "uuid": "9fe9a7c9-613e-428d-b255-93f0006cf9ad"
            }
        ],
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false
}

Now if i want to write a playbook how should i mention that only display Mount point and its available space.

3

I assume you only want to display this data not to do anything with it:

---

- hosts: all
  tasks:
    - name: show filesystems
      debug:
        msg: "mount: {{ item.mount }}, available: {{ item.size_available | human_readable }}"
      loop: "{{ ansible_mounts }}"
      loop_control:
        label: ""

This playbook will display mountpoint and avaiable size. I used loop_control to not show every item with all properties in Ansible output.

  • Thanks this is what i wanted, is it possible you can share some online documentation so that i can i understand all these all elements. Thanks – OmiPenguin Jul 30 at 9:00
  • 1
    @OmiPenguin Official Ansible doc is great so you can just dig into it: docs.ansible.com/ansible/latest/user_guide In this example I used debug module, loops and filters. – mrc02_kr Jul 30 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.