setting linux user password error with user command

44 views
Skip to first unread message

Jan Duprez

unread,
Jun 18, 2015, 10:04:51 AM6/18/15
to ansible...@googlegroups.com
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.. :-)

Matt Martz

unread,
Jun 18, 2015, 10:10:48 AM6/18/15
to ansible...@googlegroups.com
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 }}"

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/604aaab7-87c0-469c-8ff7-dad0a14d345a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Reply all
Reply to author
Forward
0 new messages