Notifying handlers only on items in loop that changed

Hello,

I was wondering if it’s possible to do something like this scenario:

  1. Create a bunch of users using a with_items loop, then notify #2
  2. Set the password on those users using the with_items loop
  3. Then at a later date, I add more users to the script and run again, but only change the password for those users that were not created.
    Thanks,

Andrew

I did this a different way to accomplish it. I created an external task and included that task looping through each user. So like this:

External task (pseudo-yaml):

  • user: name=$user …
    register: last_result

  • set_password
    shell: passwd $user
    when_changed: $last_result

Then in the playbook:

  • include myTask.yml $item
    with_items:
  • user1
  • user2

This is good!

We should put this on our Tips & Tricks page (which is sort of in
early pull request territory)

Sure, I’d be happy to submit something.

We are trying to push this to https://coderwall.com/p/t/ansible --
feel free to contribute!