# Unable to get remote target hostname when using delegate\_to

**URL:** <https://forum.ansible.com/t/unable-to-get-remote-target-hostname-when-using-delegate-to/32534>\
**Category:** Ansible Project\
**Created:** [March 26, 2020, 5:41am UTC](https://forum.ansible.com/t/unable-to-get-remote-target-hostname-when-using-delegate-to/32534 "2020-03-26T05:41:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [March 26, 2020, 5:41am UTC](https://forum.ansible.com/t/unable-to-get-remote-target-hostname-when-using-delegate-to/32534/1 "2020-03-26T05:41:35Z")

</div>

Below playbook gets the disk usage percentage of ‘/tmp’ from a list of remote\_hosts [20 remote servers] and stores it locally (delegate\_to) in a file {{ playbook\_dir }}/tmpfiles/stats.yml

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 26, 2020, 9:05am UTC](https://forum.ansible.com/t/unable-to-get-remote-target-hostname-when-using-delegate-to/32534/2 "2020-03-26T09:05:45Z")

</div>

Delegate to localhost does not change inventory\_hostname, if it did it would break a lot of code out there.  
And I can prove it with this code that mimic you codes behavior.

$ more test.yml
