Alex Hoopes
Alex Hoopes

Reputation: 39

Using Encrypted Ansible Password in Python Script

I am using Ansible to run a python script with parameters. One of these parameters are a user password

script: "{{ path_to_setup_py }} --username {{ username }} --password {{ password }} --ip {{ ip }} --hostname {{ hostname }}"

This is able to pull everything but the password, the password is a user input that is then encrypted.

name: password
prompt: Enter your password
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7

When the python script is ran, the password comes up as the hash value and doesn't use the actual password. How would I get this to decrypt the hash and then run it on the script?

Any help would be appreciated, I am a beginner.

Upvotes: 0

Views: 422

Answers (1)

mdaniel
mdaniel

Reputation: 33168

As the fine manual says, using encrypt: is really a specialization for when you are going to just send that value down into the user: module, and not interact with it further.

If you merely want the password to not echo to the screen, that is what the private: yes controls

In short, unless you have a requirement that you didn't disclose in your question, the solution is to just remove the encrypt: and salt_size: parameters:

  name: password
  prompt: Enter your password
  private: yes
  confirm: yes

Upvotes: 1

Related Questions