Run 1 playbok on multiple hosts with different passwords

681 views
Skip to first unread message

new_ansible

unread,
Apr 17, 2019, 1:15:35 AM4/17/19
to Ansible Project
Hello,

I  am trying to run ansible  playbook  on mutiple hosts  with  different  passwords.

I tried this:

ansible-playbook -i  hosts test2.yml --extra-vars "ansible_user=root ansible_password=dfth   ansible_password=yuij"

But it  connects  only one host  and  gives  authentication issue  for  another.

PLAY [Hello World!] ****************************************************************************************************************************************************

TASK [Hello World!] ****************************************************************************************************************************************************
changed: [172.20.24.xx]
fatal: [10.1.242.163]: UNREACHABLE! => {"changed": false, "msg": "Authentication failure.", "unreachable": true}
        to retry, use: --limit @/root/test/test2.retry

PLAY RECAP *************************************************************************************************************************************************************
10.1.242.xx               : ok=0    changed=0    unreachable=1    failed=0
172.20.24.xx              : ok=1    changed=1    unreachable=0    failed=0

[root@vuhplabspawx001 test]#


Please help  me to accomplish this, I  am new to ansible. :) Your prompt response is  highly appreciated


Thanks in advance.



Gonzalo Servat

unread,
Apr 17, 2019, 2:38:46 AM4/17/19
to ansible...@googlegroups.com
On Wed, Apr 17, 2019 at 3:15 PM new_ansible <vanda...@gmail.com> wrote:
Hello,

I  am trying to run ansible  playbook  on mutiple hosts  with  different  passwords.

I tried this:

ansible-playbook -i  hosts test2.yml --extra-vars "ansible_user=root ansible_password=dfth   ansible_password=yuij"

But it  connects  only one host  and  gives  authentication issue  for  another.

In your hosts file, you could define the SSH password for each host like:

[servers]
192.168.1.1 ansible_connection=ssh ansible_ssh_user=user1 ansible_ssh_pass=pass1
192.168.1.2 ansible_connection=ssh ansible_ssh_user=user1 ansible_ssh_pass=pass2
I've not tested this as I haven't used password authentication in years, but it should work.

Hope this helps.
- Gonzalo

Vandana Thakur

unread,
Apr 17, 2019, 2:56:53 AM4/17/19
to ansible...@googlegroups.com
Thanks , For your prompt response.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAHpidMAmhfCoPQfDSRHHCWo5OitxnH8te80Kdj1Rh2RBZRdNwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages