I've been bitten by this too. In my case I had this:

- name: Create plain FTP groups
  group: name={{ item.user }} gid={{ item.uid }} state={{ 
item.state|default('present') }}
  with_items: "{{ customer_ftp_accounts[inventory_hostname] }}"
  when: inventory_hostname in customer_ftp_account

I got this error:

TASK [customer_sftp : Create plain FTP groups] 
*********************************
[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future 
this will be a fatal error.: 'dict object' has no attribute u'internal'.
This feature will be removed in a future release. Deprecation warnings can 
be disabled by setting
deprecation_warnings=False in ansible.cfg.
skipping: [myserver]

It threw me off because it's purple and says "DEPRECATION WARNING", but 
it's just a regular error really. It does what I want, in so much as it 
skips hosts not in a particular list, but I could do without the error. 
It's of course fixed like this:

- name: Create plain FTP groups
  group: name={{ item.user }} gid={{ item.uid }} state={{ 
item.state|default('present') }}
  with_items: "{{ customer_ftp_accounts[inventory_hostname]|default([]) }}"

I've put a comment in the file which describes it like this:

If using "with_items", the "when" is evaluated on each iteration of the 
loop, and not when looking at the task as a whole. As such, trying to 'lock 
out' the task with a "when" won't work, and instead we have to default the 
"with_items" with an empty list if we don't want to run the loop at all.

Taking a 'step back' from this, it makes sense for Ansible to work this 
way, but it can easily catch you out as a single task (with no 
"with_items") works in a way you may mentally extrapolate out to loops.

...Ralph

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e015baf0-240b-4deb-aece-81ebe9fc6005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to