# Run 1 playbok on multiple hosts  with  different  passwords

**URL:** <https://forum.ansible.com/t/run-1-playbok-on-multiple-hosts-with-different-passwords/30131>\
**Category:** Ansible Project\
**Created:** [April 17, 2019, 5:15am UTC](https://forum.ansible.com/t/run-1-playbok-on-multiple-hosts-with-different-passwords/30131 "2019-04-17T05:15:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vandyy\_Vines](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@The\_Vandyy\_Vines](https://forum.ansible.com/u/The_Vandyy_Vines)\
**Post date:** [April 17, 2019, 5:15am UTC](https://forum.ansible.com/t/run-1-playbok-on-multiple-hosts-with-different-passwords/30131/1 "2019-04-17T05:15:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Servat](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gonzalo\_Servat](https://forum.ansible.com/u/Gonzalo_Servat)\
**Post date:** [April 17, 2019, 6:38am UTC](https://forum.ansible.com/t/run-1-playbok-on-multiple-hosts-with-different-passwords/30131/2 "2019-04-17T06:38:18Z")

</div>

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

```auto
[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

---

<div class="post-metadata">

**Author:** ![The\_Vandyy\_Vines](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@The\_Vandyy\_Vines](https://forum.ansible.com/u/The_Vandyy_Vines)\
**Post date:** [April 17, 2019, 6:56am UTC](https://forum.ansible.com/t/run-1-playbok-on-multiple-hosts-with-different-passwords/30131/3 "2019-04-17T06:56:29Z")

</div>

Thanks , For your prompt response.
