I am trying to look at our server mounts and only show those that have a specific mount available. The playbook is as follows:
Map the attribute
dn: "{{ ansible_mounts|
selectattr('device', 'contains', 'nas-server.example.com')|
map(attribute='device') }}"
If you want to skip empty lists test the length
- debug:
var: dn
when: dn|length > 0
Thank you Vladimir! I had already gotten the selectattr piece working but the length check was the missing piece. All good now.
Thanks,
Harry