Reputation: 63
I am trying to run an Ansible playbook in CLI by providing the hash of the pass.
Instead of running this command:
ansible-playbook -i inventory/inventory.yml playbooks/changedefaults.yml --extra-vars "ansible_sudo_pass=password"
I want to provide the hash of the string password
like this:
ansible-playbook -i inventory/inventory.yml playbooks/changedefaults.yml --extra-vars "ansible_sudo_pass=$6$rounds=656000$nv6b5eRCf0MA3Uth$YLcyFUT63rTMB8crCejv5IdyOYIpv62l5FVt.jjw4cNuqPX8HyYwmx/w48SFq/LJtYLrEV92mje7jV0Nfm/9g0"
How can I run this variable ansible_sudo_pass
with the hash?
Upvotes: 0
Views: 475
Reputation: 106498
You're already in a position where you're running this command (presumably) by hand, so instead of passing the password in to the playbook in an insecure fashion, use ask-become-pass
instead.
ansible-playbook -i inventory/inventory.yml playbooks/changedefaults.yml --ask-become-pass
If you have a need to do this in autonomous fashion (e.g. you're always going to become some user, or root), then you should reconsider how your playbook is structured. Using become
is largely meant to be overseen by some responsible administrator, and isn't meant to be delegated to automation.
Upvotes: 1