setting linux user password error with user command

I have a strange issue when setting passwords for a user with the user module, it seems to be mangling the password somehow. When i use a plain shell command to set the password it does work …

Code causing the error:

  • name: Add user someuser usingAnsible user module
    user: name=someuser password=“{{ someuser_password }}” groups=someuser,shadow append=yes state=present

Working workaround:

  • name: Add user someuser using shell
    shell: (echo “{{ someuser_password }}”; echo “{{ someuser_password }}”) | sudo passwd someuser

Once present the user created does some password-authenticated java commands and when i use the erronous code this all fails.
If i login to the machine manually and update the password while these calls are being made by the ansible run i see the commands start succeeding again.

The workaround gets me by for now but is not ideal

Sys info

ansible --version

ansible 1.9.1

installed from ubuntu repos w apt-get

Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise

(yeah i should be updating my ubuntu, i know… :slight_smile:

Per the documentation, the password argument should be an already crypted password:

Optionally set the user’s password to this crypted value

You can use the “password_hash” filter to create an encrypted version such as:

password=“{{ someuser_password|password_hash }}”