# Executing loop in loop

**URL:** <https://forum.ansible.com/t/executing-loop-in-loop/24249>\
**Category:** Ansible Developer\
**Created:** [April 19, 2017, 2:46pm UTC](https://forum.ansible.com/t/executing-loop-in-loop/24249 "2017-04-19T14:46:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Dasari](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@Anand\_Dasari](https://forum.ansible.com/u/Anand_Dasari)\
**Post date:** [April 19, 2017, 2:46pm UTC](https://forum.ansible.com/t/executing-loop-in-loop/24249/1 "2017-04-19T14:46:57Z")

</div>

I got a code which check whether local file exists based on with\_items and keeps result in array  
now based on this array i have to copy the local file to remote dir again using loop

- name: check wheter we have local copy plan xml file  
local\_action: stat path=“{{local\_artifacts }}/{{ item.0 }}/plan/plan.xml”  
with\_together:
- “{{ env[domain].artifact\_names }}”  
register: result

Here my results go into array, based on this result.results i want to copy the plan.xml

- name: copy deployment plan  
copy:  
src=“{{local\_artifacts }}/{{ item.0 }}/plan/plan.xml”  
dest=“{{ domain\_application\_home }}/{{ item.0 }}/plan/plan.xml”  
with\_together:

- “{{ env[domain].artifact\_names }}”  
when: result.results[0].stat.exists

at the moment this code works, but it always checks the first result.results stat, but if if want to iterate thru this result.results, how is it possible?  
Can some help me please.

---

<div class="post-metadata">

**Author:** ![Rene\_Moser](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@Rene\_Moser](https://forum.ansible.com/u/Rene_Moser)\
**Post date:** [April 19, 2017, 3:03pm UTC](https://forum.ansible.com/t/executing-loop-in-loop/24249/2 "2017-04-19T15:03:48Z")

</div>

Hi
