How to extract an object from a list based on attribute value in Jinja2? Aug 7, 2018 Use the selectattr() filter. For example: - set_fact: myobj: "{{ hostvars[inventory_hostname].ansible_mounts | selectattr('mount', 'equalto', '/') | list }}" - debug: var=myobj