# Ansible 'user' module won't set expected password

**URL:** <https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448>\
**Category:** Ansible Project\
**Created:** [September 18, 2023, 7:43pm UTC](https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448 "2023-09-18T19:43:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [September 18, 2023, 7:43pm UTC](https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448/1 "2023-09-18T19:43:23Z")

</div>

Hi - I’m trying to use the ansible.builtin.user module to set the user’s password as it creates a new user account. My task contains:

- name: Create oracle user  
ansible.builtin.user:  
name: oracle  
state: present  
uid: 54321  
group: oinstall  
groups: dba,asmdba,backupdba,dgdba,kmdba,racdba  
password: “{{ ‘ansible\_password’ | password\_hash(‘sha512’), ‘mysecretsalt’ }}”

The value of ‘ansible\_password’ is set in the inventory file; the password contains letters, numbers and special characters.

The Ansible play containing this code executes successfully. The ‘oracle’ account is created. But I’m not able to log into the account, using the value provided in the ‘ansible\_password’ value. I’ve read the Ansible documentation and Google’d around, but don’t see why this isn’t working as expected.

Thoughts, please!

Thanks  
tl

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [September 18, 2023, 7:51pm UTC](https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448/2 "2023-09-18T19:51:49Z")

</div>

Have you tried a simpler password to see whether it works?

Ko

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [September 18, 2023, 8:14pm UTC](https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448/3 "2023-09-18T20:14:31Z")

</div>

The code you posted uses the quoted literal string ‘ansible\_password’ as the password.

If you want the use the variable, then don’t use quotes:

password: “{{ ansible\_password | password\_hash(‘sha512’), ‘mysecretsalt’ }}”

Another problem could be that the variable name you picked is reserved: [https://docs.ansible.com/ansible/latest/inventory\_guide/intro\_inventory.html#connecting-to-hosts-behavioral-inventory-parameters](https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#connecting-to-hosts-behavioral-inventory-parameters)  
So pick something else, for example oracle\_user\_password.

---

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [September 18, 2023, 8:55pm UTC](https://forum.ansible.com/t/ansible-user-module-wont-set-expected-password/38448/4 "2023-09-18T20:55:59Z")

</div>

Hi Dick

Exactly! argh, I didn’t see that problem. This worked fine:

- name: Create oracle user  
ansible.builtin.user:  
name: oracle  
state: present  
uid: 54321  
group: oinstall  
groups: dba,asmdba,backupdba,dgdba,kmdba,racdba  
password: “{{ ansible\_password | password\_hash(‘sha512’) }}”

Thanks very much for the help!  
tl
