User command onöy if user does not yet exist

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.

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”)’

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

openssl passwd -salt -1

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