cancel
Showing results for 
Search instead for 
Did you mean: 
  • 3,798 Views

changing the password with ansible

I would like to change the root password and the password of some other accounts with ansible. Password is changed: it is no longer the old one, but it doesn't work.
Am I doing something wrong, or have I run into a bug?
The post is here
https://groups.google.com/g/ansible-project/c/5dXLPJWKPRg/m/5As6ZfVuBwAJ

BTW: I was searching for a stack exchange site, but there isn't one for ansible, those are very handy for end users to help each other. Very good searchable.
I think there is a need.
https://stackexchange.com/sites#

Labels (3)
7 Replies
_Komal_
Mission Specialist
Mission Specialist
  • 3,769 Views

Hey you can try using the verbose or else while creating the user you can give the password.

JoostRingoot3
Mission Specialist
Mission Specialist
  • 3,662 Views


Thanks for the reply.
What do you mean with verbose? Code example?

I need to change the password of existing users, on >200 machines, in a safe way.


I was following this procedur
https://docs.ansible.com/ansible/latest/reference_appendices/faq.html


Screenshot from 2021-06-11 20-49-25.png

Fran_Garcia
Starfighter Starfighter
Starfighter
  • 3,654 Views

I think you are hashing your password twice, and that is wrong:

 

ansible localhost -m user -a "name=jopy update_password=always password={{ '$6$sTmb9Vaxxd9fOGyC$AueAkwgO1M.qnKtKrtAFuPN5iTt0h.Dl1DcLSx9a/fqGTpltbuWAB3ZO.wsQOJTH95l3DIz/blpKFDezAzXhL.' | password_hash('sha512') }}" -u root

 

This should work:

 

ansible localhost -m user -a "name=jopy update_password=always password= '$6$sTmb9Vaxxd9fOGyC$AueAkwgO1M.qnKtKrtAFuPN5iTt0h.Dl1DcLSx9a/fqGTpltbuWAB3ZO.wsQOJTH95l3DIz/blpKFDezAzXhL.'" -u root

 

JoostRingoot3
Mission Specialist
Mission Specialist
  • 3,645 Views

Thanks for the input Fran, but it didn't work for me. (BTW: I use selection cp/paste buffer (=middle mouse button, after classic password change, it works)
Did it work for you?Screenshot from 2021-06-15 12-06-46.png

0 Kudos
_Komal_
Mission Specialist
Mission Specialist
  • 3,608 Views

The format is correct the problem is you are allready hasing the password and again using the sha512 so seems like this is creating the issue just give the normal password or you can use the variable is you are using vault to hide. And the verbose is just using -vvvv with the command it will give more clearity what is happening behind the sence.

Hope this would help you!

0 Kudos
JoostRingoot3
Mission Specialist
Mission Specialist
  • 3,620 Views

This worked:

ansible localhost -m user -a "name=jopy update_password=always password={{ 'Een.voorbeeld.passwoord' | password_hash('sha512') }}" -u root

That will have to do it then I guess

_Komal_
Mission Specialist
Mission Specialist
  • 3,613 Views

ansible -i hostfile all -m user -a "name=admin update_password=always password={{ newpassword|password_hash('sha512') }}" -b --extra-vars "newpassword=12345678"

Try using this command.

Join the discussion
You must log in to join this conversation.