Generating password randomly when user is created

38 views
Skip to first unread message

Deepa Yr

unread,
Mar 1, 2016, 6:04:28 AM3/1/16
to Ansible Project

I am running this task

- name: Create users with auto generated password
  user: name=deepa state=present password="{{ lookup('password', '/tmp/deepapassword.txt chars=ascii_letters') }}"

It is creating the file /tmp/deepapassword.txt and I see the password
But when I try to login as deepa user with that password, it says incorrect password.

Any suggestions here ? 

My requirement is to create a user with random password and use this user credentials in the subsequent tasks. 

Matt Martz

unread,
Mar 1, 2016, 8:05:57 AM3/1/16
to ansible...@googlegroups.com
The user module expects the password to already be encrypted.  You will also need to pass encrypt=True to the lookup as well.
--
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/34ab8268-7cee-4543-b4a3-212c4668cc27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Deepa Yr

unread,
Mar 1, 2016, 8:29:13 AM3/1/16
to Ansible Project
I am trying to login as deepa user from putty session to confirm that password is correct or not. I read in the documentation that password lookup generates password in a text format. So I should be able to login from putty session with that password right.


On Tuesday, March 1, 2016 at 6:35:57 PM UTC+5:30, Matt Martz wrote:
The user module expects the password to already be encrypted.  You will also need to pass encrypt=True to the lookup as well.

On Tuesday, March 1, 2016, Deepa Yr <yr.d...@gmail.com> wrote:

I am running this task

- name: Create users with auto generated password
  user: name=deepa state=present password="{{ lookup('password', '/tmp/deepapassword.txt chars=ascii_letters') }}"

It is creating the file /tmp/deepapassword.txt and I see the password
But when I try to login as deepa user with that password, it says incorrect password.

Any suggestions here ? 

My requirement is to create a user with random password and use this user credentials in the subsequent tasks. 

--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Deepa Yr

unread,
Mar 2, 2016, 7:54:02 AM3/2/16
to Ansible Project
Thanks. Understood what you suggested. It works now.


On Tuesday, March 1, 2016 at 6:35:57 PM UTC+5:30, Matt Martz wrote:
The user module expects the password to already be encrypted.  You will also need to pass encrypt=True to the lookup as well.

On Tuesday, March 1, 2016, Deepa Yr <yr.d...@gmail.com> wrote:

I am running this task

- name: Create users with auto generated password
  user: name=deepa state=present password="{{ lookup('password', '/tmp/deepapassword.txt chars=ascii_letters') }}"

It is creating the file /tmp/deepapassword.txt and I see the password
But when I try to login as deepa user with that password, it says incorrect password.

Any suggestions here ? 

My requirement is to create a user with random password and use this user credentials in the subsequent tasks. 

--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages