I have a variables file that defines a number of users:
my_users:
admin:
- admin1
- admin2
user:
- bob
I have a task that adds these users to mongodb. I don't want to execute the task every time but only if the users changed. I tried the following:
- name: add users
command: "<add users>"
when: my_users|changed
However, this does not work as intended. If I add a user, the task is still skipped.
How can I execute a task only if a variable has changed?