I'm trying to set up a few users on a Linux box using Ansible and I keep
running into a weird error. First, here's the playbook:
---
- name: common/users | ensure presence, gid of default group
group:
name: "{{ default_group.name }}"
gid: "{{ default_group.gid }}"
state: present
- name: common/users | ensure presence, sudo privileges of admin users
user:
name: "{{ default_users.username }}"
uid: "{{ default_users.uid }}"
group: "{{ default_group.name }}"
groups: sudo
state: present
and here's the `group_vars/all` file:
---
default_group:
gid: 2000
name: groupname
default_users:
- username: user1
uid: 2001
- username: user2
uid: 2002
However, when I run the playbook, I get the following error:
fatal: [vm-server]: FAILED! => {"failed": true, "msg": "the field 'args'
has an invalid value, which appears
to include a variable that is undefined. The error was: 'list object' has
no attribute 'username'
The error appears to have been in '/vagrant/roles/common/tasks/users.yml':
line 8, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: common/users | ensure presence, sudo privileges of admin users
^ here"}
My list object "default_users" is supposed to set up two users and each one
definitely contains the attribute "username", so why is it refusing to
create the users and giving me this error? My YAML seems to follow the
syntax and it passes YAMLlint <http://www.yamllint.com/> with no problem.
--
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/09b3b7b9-763f-40f4-8fb3-6c005c51aee2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.