I am trying to create somehow a nested loop with comma separated item.values in Ansible. vars: - my_resources - { name: 'share1', id: 'user1,user2,user3' } - { name: 'share2', id: 'user4' }
- name: Create users files
copy:
dest: "/etc/vsftpd_users/{{ item.id }}"
content: |
local_root=/vol/{{ item.name }}
with_items:
- "{{ my_resources.split(',') }}"
My expectation should be as below, like every file gets created with appropriate contents inside.
$ cat user1
share1
$ cat user2
share1
$ cat user4
share2
However the files created like below with the above script
-rw-r--r-- 1 root root 22 Oct 11 08:15 [u'user1', u'user2', u'user3']
-rw-r--r-- 1 root root 29 Oct 11 08:15 [u'user4']
Is there any way of fixing this issue?