# Some user of ansible\_user

**URL:** <https://forum.ansible.com/t/some-user-of-ansible-user/31082>\
**Category:** Ansible Project\
**Created:** [August 21, 2019, 6:40am UTC](https://forum.ansible.com/t/some-user-of-ansible-user/31082 "2019-08-21T06:40:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 21, 2019, 6:40am UTC](https://forum.ansible.com/t/some-user-of-ansible-user/31082/1 "2019-08-21T06:40:10Z")

</div>

I'm confused what you want to do when you use a second user. If you want fallback users, I don't know of a simple built in way but have gotten it to work looping user/pass /key combos with gather facts or a shell "sudo -l" command and register. Then loop through your registered var with set\_facts and it's possible to set for each host the first successful credential set that worked before continuing the play.

If you want different tasks to be run with different users you can use become and become\_user.

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 21, 2019, 6:47am UTC](https://forum.ansible.com/t/some-user-of-ansible-user/31082/2 "2019-08-21T06:47:04Z")

</div>

Ah I missed your detail about serial usage, but am not sure how you could do that. You could import or include a play with some sort of loop, or maybe registering a var after the final task and setting ansible\_ssh\_user to that var if it exists prior to the first task?

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 21, 2019, 8:33am UTC](https://forum.ansible.com/t/some-user-of-ansible-user/31082/3 "2019-08-21T08:33:07Z")

</div>

Hey,

I thinks you have not understand.

I have **my inventory host** with this content :

my\_host\_1 ansible\_user=wildfly  
my\_host\_1 ansible\_user=toto

When i play my playbook, ansible run playbook only on the first line **my\_host\_1 ansible\_user=wildfly** and not on the second line.  
So, same when i use **serial: 1** in my playbook, ansible run only the first line.

I think ansible refers only to the host name and does not execute every line of my inventory …?

Do you have any solution please for me community ansible !!! 🙂

Regards,

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 21, 2019, 10:12am UTC](https://forum.ansible.com/t/some-user-of-ansible-user/31082/4 "2019-08-21T10:12:45Z")

</div>

Ansible doesn't "execute lines of the inventory", it executes plays in  
a playbook.  
The inventory is to list the hosts you are targeting, so in this case  
a single host.  
Just have your inventory look like:

my\_host\_1

And then iterate over your play(s), using a different value for ansible\_user.
