In my scenario i have inventory of three machines localhost, host2 and host3. I want to run some tasks/commands on host3 while my ansible playbook is still playing on host2 without switching from host2 to host3 - is that possible? I can use local_action module but that runs the tasks on localhost but i want command to execute on host3 while i am on host2. Would be great if some one can give pointers. Below might explain what i am trying to achieve:
- name: Playing host2
hosts: host2
become: yes
tasks:
- name: run following commands on host3
local_action: command <command1 for host3>
local_action: command <command2 for host3>
- name: continue to run host2
command: <command for host2>
Is there any substitute for local_action such that i can run the commands on host3 and not on 127.0.0.1?
Many Thanks, Deepak