Generating password randomly when user is created

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.

The user module expects the password to already be encrypted. You will also need to pass encrypt=True to the lookup as well.

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.

Thanks. Understood what you suggested. It works now.