Run task only if host does not belong to a group


I’d like to able to run an ansible task only if the host of the current playbook does not belong to a certain group. In semi pseudo code:

How should I do this?


Here’s another way to do this:

group_names is a magic variable as documented here: :

group_names is a list (array) of all the groups the current host is in.

Leave a Reply