# performing a local task on every (remote) loop iteration - is that even possible?

**URL:** <https://forum.ansible.com/t/performing-a-local-task-on-every-remote-loop-iteration-is-that-even-possible/19789>\
**Category:** Ansible Project\
**Created:** [November 17, 2015, 10:22pm UTC](https://forum.ansible.com/t/performing-a-local-task-on-every-remote-loop-iteration-is-that-even-possible/19789 "2015-11-17T22:22:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [November 17, 2015, 10:22pm UTC](https://forum.ansible.com/t/performing-a-local-task-on-every-remote-loop-iteration-is-that-even-possible/19789/1 "2015-11-17T22:22:27Z")

</div>

Hi,

I'm wondering whether the following is possible with ansible only or not.

I've got a role that (besides other tasks) creates folders on remote  
hosts for every available IP address/port combination [1].

What I would need now is to perform a local task on the ansible host for  
every item/iteration of that loop.

Example:

playbook runs against 2 hosts:

hostA  
1.1.1.1  
&nbsp;&nbsp;80  
&nbsp;&nbsp;443  
2.2.2.2  
&nbsp;&nbsp;80  
&nbsp;&nbsp;443

hostB  
3.3.3.3  
&nbsp;&nbsp;80  
4.4.4.4  
&nbsp;&nbsp;80

In the end I'd like to have the following folders created on the host  
running ansible:

1.1.1.1\_80  
1.1.1.1\_443  
2.2.2.2\_80  
2.2.2.2\_443  
3.3.3.3\_80  
4.4.4.4\_80

Is that possible?

thanks,  
nusenu

[1]  
[https://github.com/nusenu/ansible-relayor/blob/master/tasks/configure.yml#L3](https://github.com/nusenu/ansible-relayor/blob/master/tasks/configure.yml#L3)

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [November 18, 2015, 5:52pm UTC](https://forum.ansible.com/t/performing-a-local-task-on-every-remote-loop-iteration-is-that-even-possible/19789/2 "2015-11-18T17:52:21Z")

</div>

solution:

[https://docs.ansible.com/ansible/playbooks\_delegation.html#delegation](https://docs.ansible.com/ansible/playbooks_delegation.html#delegation)
