title: Execute ansible task when variable has changed
body: <p>I have a variables file that defines a number of users:</p>
  
  <pre><code>my_users:
    admin:
      - admin1
      - admin2
    user:
      - bob
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>- name: add users
    command: "&lt;add users&gt;"
    when: my_users|changed
  </code></pre>
  
  <p>However, this does not work as intended. If I add a user, the task is still skipped.</p>
  
  <p>How can I execute a task only if a variable has changed?</p>