Finding key in list of dicts in when

Hi,

Related to the recent mount deprecation thread:

  • command: mount /srv
    when: “‘/srv’ not in [x[‘mount’] for x in ansible_mounts]”

But it seems that when statement is too complex. Any ideas how to express that in a valid way?

Ideas about how to use mount: state=mounted without touching fstab also welcome

Cheers,
Paul

But it seems that when statement is too complex. Any ideas how to express that in a valid way?

I ended up writing a filter that lets me do: when: not ansible_mounts|is_mounted(‘/srv’)

Cheers,
Paul

I've had some success using the following expression (to check wether
ansible is in a list of installed packages or if it is from pip/manual
install):

"{{ 'ansible' in pkgs.results|default()|map(attribute='name') }}"

Regards,
Daniel

“{{ ‘ansible’ in pkgs.results|default()|map(attribute=‘name’) }}”

Thank you Daniel, that avoids the heavy-handed approach of a filter plugin.

Cheers,
Paul