# Execute playbook on multiple users in the same host

**URL:** <https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320>\
**Category:** Ansible Project\
**Created:** [June 9, 2021, 1:47pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320 "2021-06-09T13:47:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishna\_P](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Krishna\_P](https://forum.ansible.com/u/Krishna_P)\
**Post date:** [June 9, 2021, 1:47pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/1 "2021-06-09T13:47:19Z")

</div>

Hi,

can anyone help me, how to execute ansible playbook on multiple users in the same host.

fine the below my inventory file and playbook:  
Note: it will execute only app2 if i execute the below playbook but i want to execute the playbook on all users

**Playbook:**

---

<div class="post-metadata">

**Author:** ![Krishna\_P](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Krishna\_P](https://forum.ansible.com/u/Krishna_P)\
**Post date:** [June 9, 2021, 1:49pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/2 "2021-06-09T13:49:19Z")

</div>

HI,

small correction in the previous email, Playbook is executing in app3 alone and it’s ignoring other 2

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 9, 2021, 5:46pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/3 "2021-06-09T17:46:03Z")

</div>

app1 app2 and app3 are groups, not hosts, you have a single host in  
all 4 groups, 10.0.0.1 and only one ansible\_user/ansible\_connection  
value (since they are squashed to the single host)

What you probably want is the following:

[Environment]  
app1 ansbile\_host=10.0.01 ansible\_user=user1 ...  
app2 ansible\_host=10.0.0.1 ...

Inventory hostname is the unique identifier, the above creates app1  
and app2 as 'aliases' of the same 'real host' (10.0;0.1)  
Since they are unique the variables won't be merged.

---

<div class="post-metadata">

**Author:** ![Krishna\_P](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Krishna\_P](https://forum.ansible.com/u/Krishna_P)\
**Post date:** [June 10, 2021, 3:54am UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/4 "2021-06-10T03:54:05Z")

</div>

Hi Brian,

Thanks, I tried the same and got the below error when I executed the playbook.  
**Error Screenshot:**

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/8/8abd3daba28afc384079eff7de77d1403ab18f5a.png)

I am able to login all users from an ansible control machine using ssh passwordless authentication.

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/a/a1e94a6cac78a0cb831b7dbce265c530e3134fea.png)

I have created a group level variable for each child group when I tried “parent:child” inventory but now how can assign the different variable at the time playbook execution for each user in the same host.

Thanks,  
Bala.P

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 10, 2021, 1:43pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/5 "2021-06-10T13:43:48Z")

</div>

i cannot read the error, use -vvv and post TEXT please.

---

<div class="post-metadata">

**Author:** ![Krishna\_P](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Krishna\_P](https://forum.ansible.com/u/Krishna_P)\
**Post date:** [June 10, 2021, 2:59pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/6 "2021-06-10T14:59:05Z")

</div>

Hi Brian,

I just tried once again and am now able to connect all the hosts but getting below error. I have created group variables for each user but it’s not working when I execute the playbook. can you please suggest to me how I can achieve this?

**Error Screenshot:**  
TASK [t24-app : Download R21 AMR package] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [PERU]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘t24\_unix\_product\_tmp’ is undefined\n\nThe error appears to be in ‘/oams/Bankareas/ansadmin/t24-product/roles/t24-app/tasks/main.yml’: line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# tasks file for t24-app\n- name: Download R21 AMR package\n ^ here\n”}  
fatal: [BRMB]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘t24\_unix\_product\_tmp’ is undefined\n\nThe error appears to be in ‘/oams/Bankareas/ansadmin/t24-product/roles/t24-app/tasks/main.yml’: line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# tasks file for t24-app\n- name: Download R21 AMR package\n ^ here\n”}  
fatal: [COMB]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘t24\_unix\_product\_tmp’ is undefined\n\nThe error appears to be in ‘/oams/Bankareas/ansadmin/t24-product/roles/t24-app/tasks/main.yml’: line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# tasks file for t24-app\n- name: Download R21 AMR package\n ^ here\n”}

i have created group variables like below

 ![image.png](https://us1.discourse-cdn.com/ansible/original/2X/e/e3858bbd5ddaaf25999a0c41adbecff691fe5ca9.png)

Thanks,  
Bala.P

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 10, 2021, 4:45pm UTC](https://forum.ansible.com/t/execute-playbook-on-multiple-users-in-the-same-host/35320/7 "2021-06-10T16:45:55Z")

</div>

My example had only one group, no clue what you are doing or how the diff group membership is set up, but it clearly seems they are not matching.
