Filtering with Ansible’s selectattr()/rejectattr() when the tested attribute can be absent

Ansible’s selectattr and rejectattr allow filtering of a list of dictionaries based on a specific test being executed against each dictionary’s keys and values. But what if the dictionary is not guaranteed to always have the key being tested actually defined?

How to modify a list of dictionaries with Ansible

I keep running into scenarios with Ansible for which there doesn’t seem a ready StackOverflow or Serverfault answer and which usually prompts a “You must be doing something very strange that Ansible was not made for” answer from my Belgian friends. One of these scenarios is how to modify an existing list of dictionaries with… Continue reading How to modify a list of dictionaries with Ansible