# Creating a user and setting password only when getent returns a null value from passwd database.

**URL:** <https://forum.ansible.com/t/creating-a-user-and-setting-password-only-when-getent-returns-a-null-value-from-passwd-database/24144>\
**Category:** Ansible Project\
**Created:** [April 4, 2017, 8:33pm UTC](https://forum.ansible.com/t/creating-a-user-and-setting-password-only-when-getent-returns-a-null-value-from-passwd-database/24144 "2017-04-04T20:33:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.lovely25](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@michael.lovely25](https://forum.ansible.com/u/michael.lovely25)\
**Post date:** [April 4, 2017, 8:33pm UTC](https://forum.ansible.com/t/creating-a-user-and-setting-password-only-when-getent-returns-a-null-value-from-passwd-database/24144/1 "2017-04-04T20:33:53Z")

</div>

i am trying to get this to work, but its skipping over user creation in this current form when getent returns a null answer

---

<div class="post-metadata">

**Author:** ![michael.lovely25](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@michael.lovely25](https://forum.ansible.com/u/michael.lovely25)\
**Post date:** [April 4, 2017, 9:02pm UTC](https://forum.ansible.com/t/creating-a-user-and-setting-password-only-when-getent-returns-a-null-value-from-passwd-database/24144/2 "2017-04-04T21:02:38Z")

</div>

_Edit_ fail\_key=false

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 5, 2017, 10:05am UTC](https://forum.ansible.com/t/creating-a-user-and-setting-password-only-when-getent-returns-a-null-value-from-passwd-database/24144/3 "2017-04-05T10:05:35Z")

</div>

Here you say run user module when getent\_passwd[user\_name] is not none/null, aka the user already exist.  
Change it to "==" instead of "!=" and it should work.
