# Looping tasks across different hosts

**URL:** <https://forum.ansible.com/t/looping-tasks-across-different-hosts/20316>\
**Category:** Ansible Project\
**Created:** [January 22, 2016, 3:22pm UTC](https://forum.ansible.com/t/looping-tasks-across-different-hosts/20316 "2016-01-22T15:22:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Newing](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@Peter\_Newing](https://forum.ansible.com/u/Peter_Newing)\
**Post date:** [January 22, 2016, 3:22pm UTC](https://forum.ansible.com/t/looping-tasks-across-different-hosts/20316/1 "2016-01-22T15:22:36Z")

</div>

Hi Everyone,  
First post so bear with me please…  
We’re doing some work with Hazelcast shared memory across multiple hosts.  
Something will get added into the shared memory on host A and I want to check it exists from host B, C etc.  
Sounds like a with\_items loop… (do this, check this, do this, check this)  
But how can I run one task on one host and another task on the other node(s) within a loop.  
I’m thinking blocks and maybe delegate\_to?  
I could obvious hard code the individual steps into one big playbook without a loop.  
But I’m looking for something elegant that would only need the do/check list to be updated for new items.  
Any thoughts?  
FYI I’m running ansible 2.1.0 on CentOS 7…  
Thanks, Pete
