# delegate\_to works incorrectly with with\_items

**URL:** <https://forum.ansible.com/t/delegate-to-works-incorrectly-with-with-items/19175>\
**Category:** Ansible Project\
**Created:** [September 3, 2015, 7:36am UTC](https://forum.ansible.com/t/delegate-to-works-incorrectly-with-with-items/19175 "2015-09-03T07:36:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman\_Belyakovsky](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Roman\_Belyakovsky](https://forum.ansible.com/u/Roman_Belyakovsky)\
**Post date:** [September 3, 2015, 7:36am UTC](https://forum.ansible.com/t/delegate-to-works-incorrectly-with-with-items/19175/1 "2015-09-03T07:36:31Z")

</div>

Hello!

I have an issue: delegate\_to works incorrectly with with\_items. I cannot collect missing facts. I’ve opened an [issue](https://github.com/ansible/ansible/issues/12222) but it was already closed. Is there anything wrong with my playbook?

Thank you,  
Yours Faithfully,  
Roman Belyakovsky

---

<div class="post-metadata">

**Author:** ![Takeshi\_Yaegashi](https://avatars.discourse-cdn.com/v4/letter/t/838e76/32.png) [@Takeshi\_Yaegashi](https://forum.ansible.com/u/Takeshi_Yaegashi)\
**Post date:** [September 5, 2015, 10:35am UTC](https://forum.ansible.com/t/delegate-to-works-incorrectly-with-with-items/19175/2 "2015-09-05T10:35:16Z")

</div>

Hi,

It seems setup module with delegate\_to doesn’t work as intended in Ansible prior to 2.0. It actually updates facts of self (hostvars[inventory\_hostname]) with facts of delegated host. Ansible 2.0 successfully updates delegated host’s hostvars. Confirmed with the following playbook:

`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 6, 2015, 7:11pm UTC](https://forum.ansible.com/t/delegate-to-works-incorrectly-with-with-items/19175/3 "2015-09-06T19:11:55Z")

</div>

Until 2.0 getting facts was always updating the 'delegated for' host,  
in 2.0 we changed it so it updates the 'delegated to' host.

Before 2.0 the only way to get facts for machines not in your play was  
to gather them in a previous play and either run that play at the same  
time as the play that used them or use persistent fact caching to make  
them available.
