Trying to get a playbook working with yml file containing 2 lists and 
passing that into the main file to loop over.

Can someone help with letting me know what I'm doing wrong? Thanks
 
copylist.yml
---
copylist:
    src:
      - /home/ansible/tom/tom.txt
      - /home/ansible/fred/fred.txt
    dest:
      - /home/ansible/tom1
      - /home/ansible/fred1

Playbook - copy.yml
---
- hosts: localhost
  become: yes
  vars:
    users:
      - tom
      - fred
  vars_files:
      - copylist.yml
  tasks:
    - name: Create users from vars
      user:
        name: "{{item}}"
        state: present
      with_items: "{{users}}"


    - name: Copy files into target directories
      copy:
        src: "{{item.src}}"
        dest: "{{item.dest}}"
      with_items: "{{copylist}}"

Playbook output - 

TASK [Copy files into target directories] 
**************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' 
has an invalid value, which appears to include a variable that is 
undefined. The error was: 'ansible.vars.unsafe_proxy.AnsibleUnsafeText 
object' has no attribute 'dest'\n\nThe error appears to have been in 
'/etc/ansible/playbooks/copy.yml': line 18, column 7, but may\nbe elsewhere 
in the file depending on the exact syntax problem.\n\nThe offending line 
appears to be:\n\n\n    - name: Copy files into target directories\n      ^ 
here\n"}





-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/14ae41d4-bd60-425e-9862-26108daad3b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to