I am trying to look at our server mounts and only show those that have a
specific mount available. The playbook is as follows:
---
- hosts: all_hosts
become: true
become_method: sudo
gather_facts: true
tasks:
- name: Get mount points
ansible.builtin.set_fact:
device_names: "{{ ansible_mounts | selectattr('device', 'contains',
'nas-server.example.com') | list }}"
- name: List servers with those mount points
ansible.builtin.debug:
msg: "{{ device_names }}"
I have 2 small issues with the output:
1) The device_names shows everything about that mount and I only want to
show the device attribute;
2) Hosts that do not have the mount present show up in my debug list with
an empty string. I'd like to not show them at all if possible.
ok: [server1.example.com] => {
"msg": [
{
"block_available": 26201799211,
"block_size": 4096,
"block_total": 36234081792,
"block_used": 10032282581,
"device": "nas-server.example.com:/projects",
"fstype": "fuse.glusterfs",
"inode_available": 14493376449,
"inode_total": 14495510592,
"inode_used": 2134143,
"mount": "/projects",
"options":
"rw,nodev,relatime,user_id=0,group_id=0,allow_other,max_read=131072",
"size_available": 107322569568256,
"size_total": 148414799020032,
"uuid": "N/A"
}
]
}
ok: [server2.example.com] => {
"msg": []
}
Thanks for any help,
Harry
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b724b0c0-93e7-4516-b839-73dd7141cb94n%40googlegroups.com.