Ansible find object in list by value of object field


I have this structure. For each host this structure may have more or less items. In a task I want to know if there is a a module defined with a particular name.

For instance I want to know if the module_name Reporting is defined so that I include a set of tasks for it.

How do I get this to work?
Is there a better way?


You can create a list of values of a key from your web_module_list and check if a string is on that list:

You might want to set a fact for the list, so that the filtering is not repeated, but with Ansible it’s rather a matter of clarity than performance.

Leave a Reply