Execute playbook on multiple users in the same host

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:

HI,

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

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.

Hi Brian,

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

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

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

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

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

Thanks,
Bala.P

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.