when: var is defined deprecated?

using ansible 2.1.1.0

running a task with ‘when: users is defined’ works fine for hosts that have that variable. for hosts that dont, the play still runs, but gives a warning that in the future, an undefined variable will be a fatal error. is there another way of running tasks based on the existence of a given var?

You should generally provide your full task, so I’m going to take a guess here.

I am pretty sure the problem is that you are using with_items: users also. The problem is that when statements are evaluated after with_items, since the when statement is evaluated per item in the loop.

yes. used a group so the when was not needed.