Struggled with this problem for few days and finally managed to fix it.
1. Removed ansible from the machine (deleted everything)
ansible --version
ansible 2.0.1.0 (detached HEAD bec698052f) last updated 2016/02/22 11:04:54
(GMT +100)
lib/ansible/modules/core: (detached HEAD 9552a22b83) last updated 2016/02/
22 11:04:59 (GMT +100)
lib/ansible/modules/extras: (detached HEAD 51cddf2b35) last updated 2016/
02/22 11:05:05 (GMT +100)
config file =
configured module search path = Default w/o overrides
2. Executed following code:
- name: Synchronize files
delegate_to: "{{ inventory_hostname }}"
synchronize:
recursive: yes
links: yes
times: yes
src: "{{ item.source }}"
dest: "{{ item.dest }}"
with_items:
- { source: '{{ some_path }}/some.git/file.txt', dest:
'/abc/def/file.txt' }
--> works ok
I have had multiple syntax errors in my "code" but by some reason had more
problems with 2.0.0.2 and 22th Feb 2016 git version seems to work better
for me.
Found out that one error that I had was one space character indentation
before the block and previous block was without the indentation so that
caused one error. However; there were multiple other small syntax errors.
On Friday, 19 February 2016 10:49:34 UTC+2, AS wrote:
>
> 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/f40edb8f-7d0d-41c1-b9e3-875141957cb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.