# ERROR! duplicate loop in task: - please explain why

**URL:** <https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262>\
**Category:** Ansible Project\
**Created:** [January 19, 2016, 4:34am UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262 "2016-01-19T04:34:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu1](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Steve\_Kieu1](https://forum.ansible.com/u/Steve_Kieu1)\
**Post date:** [January 19, 2016, 4:34am UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262/1 "2016-01-19T04:34:34Z")

</div>

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

---

<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:** [January 19, 2016, 4:55pm UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262/2 "2016-01-19T16:55:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu1](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Steve\_Kieu1](https://forum.ansible.com/u/Steve_Kieu1)\
**Post date:** [January 19, 2016, 11:52pm UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262/3 "2016-01-19T23:52:45Z")

</div>

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?

---

<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:** [January 19, 2016, 11:58pm UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262/4 "2016-01-19T23:58:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu1](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Steve\_Kieu1](https://forum.ansible.com/u/Steve_Kieu1)\
**Post date:** [February 5, 2016, 6:16am UTC](https://forum.ansible.com/t/error-duplicate-loop-in-task-please-explain-why/20262/5 "2016-02-05T06:16:42Z")

</div>

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
