Trying to create users and groups with vars inline...this is not 
working..what am I missing here?

--- # Users and Groups
- hosts: localhost
  become: yes
  vars:
     groups:
        - devops
        - dbadbmins
        - serveradmins

     users:
        - frank
        - joe
        - dave
  tasks:
    - name: Create groups
      group:
        name: "{{ item.groups }}"
        state: present
      with_items: "{{groups}}"
      ignore_errors: yes

    - name: Create users
      user:
        name: "{{ item.user }}"
        state: present
      with_items: "{{users}}"

Output - 

PLAY [localhost] 
*********************************************************************

TASK [Gathering Facts] 
***************************************************************
ok: [localhost]

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

TASK [Create 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 'user'\n\nThe error appears to have been in 
'/etc/ansible/playbooks/usersgroups.yml': line 22, 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: Create users\n      ^ 
here\n"}
        to retry, use: --limit @/etc/ansible/playbooks/usersgroups.retry




-- 
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/101e21f7-995b-4661-8027-740ddf230cfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to