# User command onöy if user does not yet exist

**URL:** <https://forum.ansible.com/t/user-command-onoy-if-user-does-not-yet-exist/13682>\
**Category:** Ansible Project\
**Created:** [October 15, 2013, 3:18pm UTC](https://forum.ansible.com/t/user-command-onoy-if-user-does-not-yet-exist/13682 "2013-10-15T15:18:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_de\_Groot](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@Manuel\_de\_Groot](https://forum.ansible.com/u/Manuel_de_Groot)\
**Post date:** [October 15, 2013, 3:18pm UTC](https://forum.ansible.com/t/user-command-onoy-if-user-does-not-yet-exist/13682/1 "2013-10-15T15:18:17Z")

</div>

Can someone give me a hint/example how this works: password={{ initial\_password }}  
I don’t get it how that {{ initial\_password }} part works.

Thanks.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [October 15, 2013, 6:02pm UTC](https://forum.ansible.com/t/user-command-onoy-if-user-does-not-yet-exist/13682/2 "2013-10-15T18:02:56Z")

</div>

I’m using it in a task like this:

- name: ‘User | Create All Required Users’  
user: name={{ item }}  
group=root  
groups=root,sudo  
home=/home/{{ item }}  
generate\_ssh\_key=yes  
ssh\_key\_bits=2048  
shell=/bin/bash  
password={{ initial\_password }}  
update\_password=on\_create  
with\_items: $admins

And the variable initial\_password is defined in a variable file:

initial\_password: ‘sOmEcOdE’

‘sOmEcOdE’ is the result of a command line like this:

python -c ‘import crypt; print crypt.crypt(“firstpassword”, “someSalt”)’

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 15, 2013, 11:40pm UTC](https://forum.ansible.com/t/user-command-onoy-if-user-does-not-yet-exist/13682/3 "2013-10-15T23:40:54Z")

</div>

A bit hidden, but this is also shown in a few places in the docs, including the password parameter docs for the user module:

[http://www.ansibleworks.com/docs/modules.html#user](http://www.ansibleworks.com/docs/modules.html#user)

openssl passwd -salt -1

So no need for the Python code for those that might find that uncomfortable or hard to remember.
