# strange creating directory with delegate\_to

**URL:** <https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795>\
**Category:** Ansible Project\
**Created:** [July 17, 2015, 7:31am UTC](https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795 "2015-07-17T07:31:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [July 17, 2015, 7:31am UTC](https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795/1 "2015-07-17T07:31:43Z")

</div>

when running

`

- debug: var=groups.control

- name: Create facts.d directory on ops-control  
file:  
state: directory  
path: /etc/ansible/facts.d  
sudo: yes  
delegate\_to: “{{groups.control}}”  
`

i get

`  
TASK: [debug var=groups.control] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [127.0.0.1] =\> {  
“var”: {  
“groups.control”: [  
“10.0.196.112”  
]  
}  
}

TASK: [Create facts.d directory on ops-control] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [127.0.0.1 → [u’10.0.196.112’]] =\> Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/ansible/runner/ **init**.py”, line 582, in \_executor  
exec\_rc = self.\_executor\_internal(host, new\_stdin)  
File “/usr/local/lib/python2.7/dist-packages/ansible/runner/ **init**.py”, line 785, in \_executor\_internal  
return self.\_executor\_internal\_inner(host, self.module\_name, self.module\_args, inject, port, complex\_args=complex\_args)  
File “/usr/local/lib/python2.7/dist-packages/ansible/runner/ **init**.py”, line 923, in \_executor\_internal\_inner  
delegate = self.\_compute\_delegate(actual\_pass, inject)  
File “/usr/local/lib/python2.7/dist-packages/ansible/runner/ **init**.py”, line 363, in \_compute\_delegate  
delegate[‘user’] = self.\_compute\_delegate\_user(self.delegate\_to, delegate[‘inject’])  
File “/usr/local/lib/python2.7/dist-packages/ansible/runner/ **init**.py”, line 393, in \_compute\_delegate\_user  
if host in inject[‘hostvars’]:  
TypeError: unhashable type: ‘list’  
`

I’ve not yet seen this kind of error yet.

---

<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:** [July 17, 2015, 1:19pm UTC](https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795/2 "2015-07-17T13:19:50Z")

</div>

delegate\_to does not take lists, groups.control is a list, you need to  
give it a single item or use with\_items to cycle through the list.

In any case this is a bug as you should not get a traceback, but a  
nice error message that tells you something similar to what i said  
above.

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [July 18, 2015, 2:56am UTC](https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795/3 "2015-07-18T02:56:04Z")

</div>

Ah, yes. Thanks!

---

<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:** [July 18, 2015, 2:59am UTC](https://forum.ansible.com/t/strange-creating-directory-with-delegate-to/18795/4 "2015-07-18T02:59:37Z")

</div>

This should be fixed in 2.0 (current devel)
