# inconsistent behaviour with user module

**URL:** <https://forum.ansible.com/t/inconsistent-behaviour-with-user-module/14999>\
**Category:** Ansible Project\
**Created:** [April 11, 2014, 12:33pm UTC](https://forum.ansible.com/t/inconsistent-behaviour-with-user-module/14999 "2014-04-11T12:33:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bretgiddings](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@bretgiddings](https://forum.ansible.com/u/bretgiddings)\
**Post date:** [April 11, 2014, 12:33pm UTC](https://forum.ansible.com/t/inconsistent-behaviour-with-user-module/14999/1 "2014-04-11T12:33:06Z")

</div>

I am trying to use a simple ansible playbook to automate changing the root password. However, on 4 of my hosts, the password is changed each time I run the playbook. So, with the simple playbook password.yml consisting of

---

<div class="post-metadata">

**Author:** ![bretgiddings](https://avatars.discourse-cdn.com/v4/letter/b/77aa72/32.png) [@bretgiddings](https://forum.ansible.com/u/bretgiddings)\
**Post date:** [April 14, 2014, 2:20pm UTC](https://forum.ansible.com/t/inconsistent-behaviour-with-user-module/14999/2 "2014-04-14T14:20:12Z")

</div>

SOLVED.

I’m not sure that it will help anyone else, but I found the cause of the problem. The 4 problem hosts had both passwd and shadow files and for some historical reason had a password hash in both files. As ansible was using getpwnam to lookup the user details, it was getting the password hash from /etc/passwd. I’m guessing that getpwnam doesn’t look in /etc/shadow if the password field isn’t ‘x’. However, ansible uses usermod to change the password. This must just detect that there is an /etc/shadow file and updates the password field in this. The result was that it was always different and needed updating.

Setting /etc/passwd to use ‘x’ (as it should) cures the problem.
