ERROR! duplicate loop in task: - please explain why

1,024 views
Skip to first unread message

Steve Kieu

unread,
Jan 18, 2016, 11:34:34 PM1/18/16
to Ansible Project
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
---

- name: Install postgres93
  yum: name={{item}} state=present
  with_items:
    - "{{cron_pkgname}}"
    - "{{mail_pkgname}}"
    - "rdiff-backup"
    - "which"
    - "postgresql93-server"
    - "postgresql93-contrib"
  env: proxy_env

- name: yum clean up cache
  shell: yum clean all; yum clean metadata
  when: do_cleanup == 'yes'

# vim:expandtab ts=2 sw=2

This run perfectly fine with ansible 1.9.x 

Please help.

Brian Coca

unread,
Jan 19, 2016, 11:56:06 AM1/19/16
to Ansible Project
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.



--
Brian Coca

Steve Kieu

unread,
Jan 19, 2016, 6:52:46 PM1/19/16
to Ansible Project
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?

Brian Coca

unread,
Jan 19, 2016, 6:58:55 PM1/19/16
to Ansible Project
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.



--
Brian Coca

Steve Kieu

unread,
Feb 5, 2016, 1:16:43 AM2/5/16
to Ansible Project
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.
<test-pg1-all> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO test-pg1-all
<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 )"'
<test-pg1-all> 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
Reply all
Reply to author
Forward
0 new messages