strange creating directory with delegate_to

90 views
Skip to first unread message

Barry Kaplan

unread,
Jul 17, 2015, 3:31:43 AM7/17/15
to ansible...@googlegroups.com
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.

Brian Coca

unread,
Jul 17, 2015, 9:19:56 AM7/17/15
to ansible...@googlegroups.com
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.



--
Brian Coca

Barry Kaplan

unread,
Jul 17, 2015, 10:56:05 PM7/17/15
to ansible...@googlegroups.com

On Friday, July 17, 2015 at 6:49:56 PM UTC+5:30, Brian Coca wrote:
delegate_to does not take lists, groups.control is a list, 

Ah, yes. Thanks! 

Brian Coca

unread,
Jul 17, 2015, 10:59:41 PM7/17/15
to ansible...@googlegroups.com
This should be fixed in 2.0 (current devel)
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a2b4a1eb-ff98-463d-b0f6-bb318b5a7e71%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages