What is the correct way to use with_Items to loop over two files? The 
playbook is failing at the 2nd task

Getting an error - TASK [Create users from vars users] 
********************************************
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 'users'\n\nThe error appears to have been in 
'/etc/ansible/playbooks/exercises/usersgroups.yml': line 15, column 6, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n   - name: Create users from vars 
users\n     ^ here\n"}

users.yml (is below, grouplist.yml is similar)
---
users:
- jock
- dejan
- joel

Playbook is below -

    - users.yml
    - grouplist.yml
  tasks:

   - name: Create groups from vars file
     group:
        name: "{{item}}"
        state: present
     with_items: "{{grouplist}}"

   - name: Create users from vars users
     user:
        name: "{{item.users}}"
        state: present
        groups: "{{item.grouplist}}"
     with_items:
         - "{{ users}}"
         - "{{grouplist}}"

-- 
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/6598ea3a-4feb-4063-b0a3-7185d8e56ada%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to