1

My command line is

ansible-playbook *playbook-name* --ask-become-pass

In this case ansible will ask for the password.

I want to use the same command but without having to put the password interactively. something like

ansible-playbook *playbook-name* --ask-become-pass < password

(which don't work of course)

ponury-kostek
  • 7,824
  • 4
  • 23
  • 31
myuri
  • 21
  • 1
  • 4
  • you should consider using key based ssh, instead of using password – tux May 30 '17 at 10:16
  • yes but my playbook needs the ask-become-pass option in order to switch from user to another. Basically i have two user on my remote machine i used ssh key for the first one and password for the second one. (i switch to the second one using using "become" and sudo. The password i need to pass here is the password of the user of the ansible master machine itself – myuri May 30 '17 at 11:51
  • Possible duplicate of [Specify sudo password for Ansible](https://stackoverflow.com/questions/21870083/specify-sudo-password-for-ansible) – techraf May 30 '17 at 12:01
  • not exactly the same issue. Here it it's really related to sudo of the ansible user itself and not the sudo of the remote machine – myuri May 30 '17 at 12:42
  • It is **exactly** the same issue. You might be confused by the old parameter names, but did you bother to read the accepted answer? – techraf May 30 '17 at 12:49
  • it did'nt work it does not take the password into account – myuri May 30 '17 at 15:19

1 Answers1

1

I have fixed my issue by removing the --ask-become-pass option and i set the ansible_become_pass variable in my inventory (and encrypted the password by vault). Therefore, during the sudo operation ansible use the password i provided to "become" another user

myuri
  • 21
  • 1
  • 4