Do you guys know why ansible gives me an error 'item' is undefined on this
specific case?
Version:
Ansible 2.0.0.2
Ubuntu 15.10
- name: Synchronize files
synchronize:
src: "{{ item.source }}"
dest: "{{ item.dest }}"
recursive: yes
links: yes
times: yes
rsync_opts: "--devices"
with_items:
- { source: project/conf/file.conf, dest: /etc/asdf/nginx.conf }
- { source: project/conf/somefolder/, dest: /etc/asdf/somefolder/ }
- { source: /conf/asdf/anotherfolder/, dest: /etc/asfd/anotherfolder/
}
Result:
TASK [mumbojumbo: Synchronize files]
***********************************************
task path: /home/asdf/wef/main.yml:27
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"failed": true, "msg": "ERROR! 'item'
is undefined"}
*Second problem with the same case:*
By some reason using quotes causes an Syntax error?
- name: Synchronize files
synchronize:
src: "{{ item.source }}"
dest: "{{ item.dest }}"
recursive: yes
links: yes
times: yes
rsync_opts: "--devices"
with_items:
- { source: 'project/conf/file.conf', dest: '/etc/asdf/nginx.conf' }
- { source: 'project/conf/somefolder/', dest: '/etc/asdf/somefolder/'
}
- { source: '/conf/asdf/anotherfolder/', dest:
'/etc/asfd/anotherfolder/' }
-->
ERROR! Syntax Error while loading YAML.
The error appears to have been in
'/home/osboxes/analytics/tstdeployment/roles/orfer/tasks/main.yml': line
36, column 86, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
with_items:
- { source: 'project/conf/file.conf', dest: '/etc/asdf/nginx.conf' }
^
here
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
when: "ok" in result.stdout
Could be written as:
when: '"ok" in result.stdout'
Or equivalently:
when: "'ok' in result.stdout"
--
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/28ef1e4f-b959-4774-923a-fe4f1b116be9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.