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

-- 
Vladimir Botka

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20230927213245.3f39b2f8%40gmail.com.

Attachment: pgpHL7pnDuN1i.pgp
Description: OpenPGP digital signature

Reply via email to