# Want to run ansible tasks on remote host

**URL:** <https://forum.ansible.com/t/want-to-run-ansible-tasks-on-remote-host/22853>\
**Category:** Ansible Project\
**Created:** [October 21, 2016, 12:28pm UTC](https://forum.ansible.com/t/want-to-run-ansible-tasks-on-remote-host/22853 "2016-10-21T12:28:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepak.dimri2016](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@deepak.dimri2016](https://forum.ansible.com/u/deepak.dimri2016)\
**Post date:** [October 21, 2016, 12:28pm UTC](https://forum.ansible.com/t/want-to-run-ansible-tasks-on-remote-host/22853/1 "2016-10-21T12:28:42Z")

</div>

In my scenario i have inventory of three machines localhost, host2 and host3. i am using localhost as ansible machine to run my playbooks. 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? Below might explain what i am trying to achieve:

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

```

I tried using delegate\_to: host3 but then i am getting **Failed to connect to the host via ssh**

`  
-name: Playing host2

hosts: host2

become:yes

tasks:

- name: run following commands on host3

shell:

shell:

shell:

delegate\_to: host2

remote\_user: centos  
`

Can anyone please suggest?

Thanks,

Deepak
