# local or remote execution

**URL:** <https://forum.ansible.com/t/local-or-remote-execution/29676>\
**Category:** Ansible Developer\
**Created:** [February 14, 2019, 1:17am UTC](https://forum.ansible.com/t/local-or-remote-execution/29676 "2019-02-14T01:17:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dmitriy\_Trubov](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dmitriy\_Trubov](https://forum.ansible.com/u/Dmitriy_Trubov)\
**Post date:** [February 14, 2019, 1:17am UTC](https://forum.ansible.com/t/local-or-remote-execution/29676/1 "2019-02-14T01:17:16Z")

</div>

Hi,

I have ansible task

- shell: “python task.py”  
register: result  
until: result.stdout.find(“in-progress”)==-1  
retries: 7  
delay: 20

python module executed remotely on target host.

Where is executed verification on string “in-progress” ? locally where playbook code executed or remotely?  
If it is executed remotely “ssh” connection will be allocated during whole execution…

Thanks,  
Dmitriy

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [February 14, 2019, 5:49am UTC](https://forum.ansible.com/t/local-or-remote-execution/29676/2 "2019-02-14T05:49:27Z")

</div>

It depends on how your hosts is defined st the play level.

Assuming your play is targeting a remote host then your task will be running on the remote host.

If you need to run some task locally while the rest of the tasks remotely you can use delegate\_to: localhost on that one task.

Regards  
Tony

---

<div class="post-metadata">

**Author:** ![Dmitriy\_Trubov](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dmitriy\_Trubov](https://forum.ansible.com/u/Dmitriy_Trubov)\
**Post date:** [February 14, 2019, 6:42am UTC](https://forum.ansible.com/t/local-or-remote-execution/29676/3 "2019-02-14T06:42:14Z")

</div>

Hi, I figured out.  
Comparison happened locally,-vvvvv option shows that after every python execution ssh connection dropped

Thanks,  
Dmitriy
