ERROR! duplicate loop in task: - please explain why

Hi Team,

I am trying ansible 2 and not sure why it got error below

TASK [postgres : include] ******************************************************
task path: /home/stevek/ansible-jumbo/roles/postgres/tasks/main.yml:10
fatal: [test-pg-all]: FAILED! => {“failed”: true, “reason”: “ERROR! duplicate loop in task: items\n\nThe error appears to have been in ‘/home/stevek/ansible-jumbo/roles/postgres/tasks/01-install.yml’: line 7, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Install postgres93\n ^ here\n”}

cat /home/stevek/ansible-jumbo/roles/postgres/tasks/01-install.yml

env: proxy_env?

there is no such directive, i'm guessing you want:

environment: "{{proxy_env}}"

2.0 is now better at validating playbooks and unlike previous
versions it does not ignore incorrect entries. The error message
itself seems a bit confusing, but it does point at the correct task.

Hi Brian,

proxy_env is a dict defined in inventory/group/all files. I have the code:

  • name: Install postgres93
    yum: name={{item}} state=present
    with_items:
  • “{{cron_pkgname}}”
  • “{{mail_pkgname}}”
  • rdiff-backup
  • which
  • postgresql93-server
  • postgresql93-contrib
    environment: proxy_env

that works with version 1.9.x

But v2 refuse to run that code saying expected a dict and got proxy_env. When I switch to env: proxy_env it stopped complaining about it. Probably it is still error at this but give different error message.

How do I specify proxy_env in v2? Or is it a bug?

already gave you the solution:

environment: "{{proxy_env}}"

environment won't take bare vars to confuse with strings in 2.0, it
will properly validate.

Hi there,

I did use it (quote them and put {{}} around) but still got errors

TASK [postgres : Install postgres93] *******************************************
task path: /home/stevek/ansible-jumbo/roles/postgres/tasks/01-install.yml:7
[DEPRECATION WARNING]: Using bare variables for environment is deprecated. Update your playbooks so that the environment
value uses the full variable syntax (‘{{foo}}’). This feature will be removed in a future release. Deprecation warnings
can be disabled by setting deprecation_warnings=False in ansible.cfg.
ESTABLISH CONNECTION FOR USER: root on PORT 22 TO test-pg1-all
EXEC /bin/sh -c ‘mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1454651909.82-26088368040824 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1454651909.82-26088368040824 )”’
PUT /tmp/tmp1tF9fp TO /root/.ansible/tmp/ansible-tmp-1454651909.82-26088368040824/yum
fatal: [test-pg1-all]: FAILED! => {“failed”: true, “msg”: “environment must be a dictionary, received proxy_env (<class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>)”}

The proxy_env is a dictionary declared in inventory

proxy_env:
dummy: dummy

So it wont work. How can I make it work then?

Thanks