I wish to use a when statement that takes a variable passed in at command line (user), check it against a variable created with getent: (database: passwd). I am doing something wrong. I think the issue is two fold. 1. I think that I am not using my variables right in the when statement. 2. In this context, would I need to be pointing to local_users.ansible_facts.getent_passwd? or something similar?:
I thought about that, don’t know why I didn’t just go with it. Out of curiosity though, what is wrong with my when statement (in case I use it in the future in a different scenario, I want to be able to reference this forum)?
when: user in local_users[‘ansible_facts’][‘getent_passwd’]
Thank you Brian. Why local_users[‘ansible_facts’][‘getent_passwd’] vs local_users.ansible_facts.getent_passwd. Is that a preference? or is there reasoning behind it?