Following up on myself:
If I change the roles/groups_users/tasks/main.yml to this:
---
- name: Add groups
group: name={{ item.name }}
with_dict: groups
- name: Add users
user: name={{ item.name }}
uid={{ item.uid }}
with_items: users
i.e. *with_dict* instead of *with_items* in the Add groups task, then I
don't get an error. However the output of --check does not look like it is
doing what I'd expect. Also why does the "Add users" task not need
with_dict instead of "with_items"?!
GATHERING FACTS
***************************************************************
ok: [host1]
ok: [host3]
ok: [host2]
TASK: [groups_users | Add groups]
*********************************************
skipping: [host1] => (item={'key': 'ungrouped', 'value': []})
skipping: [host1] => (item={'key': 'myhosts', 'value': ['host1', 'host2',
'host3']})
skipping: [host2] => (item={'key': 'ungrouped', 'value': []})
skipping: [host1] => (item={'key': 'all', 'value': ['host1', 'host2',
'host3']})
skipping: [host2] => (item={'key': 'myhosts', 'value': ['host1', 'host2',
'host3']})
skipping: [host1] => (item={'key': 'groups_users_db', 'value': ['host3']})
skipping: [host2] => (item={'key': 'all', 'value': ['host1', 'host2',
'host3']})
skipping: [host3] => (item={'key': 'ungrouped', 'value': []})
skipping: [host1] => (item={'key': 'groups_users_sysadmins', 'value':
['host1', 'host2', 'host3']})
skipping: [host2] => (item={'key': 'groups_users_db', 'value': ['host3']})
skipping: [host3] => (item={'key': 'myhosts', 'value': ['host1', 'host2',
'host3']})
skipping: [host2] => (item={'key': 'groups_users_sysadmins', 'value':
['host1', 'host2', 'host3']})
skipping: [host3] => (item={'key': 'all', 'value': ['host1', 'host2',
'host3']})
skipping: [host3] => (item={'key': 'groups_users_db', 'value': ['host3']})
skipping: [host3] => (item={'key': 'groups_users_sysadmins', 'value':
['host1', 'host2', 'host3']})
TASK: [groups_users | Add users]
**********************************************
skipping: [host1] => (item={'name': 'username3', 'uid': 3456})
skipping: [host1] => (item={'name': 'username4', 'uid': 4567})
skipping: [host3] => (item={'name': 'username3', 'uid': 3456})
skipping: [host2] => (item={'name': 'username3', 'uid': 3456})
skipping: [host3] => (item={'name': 'username4', 'uid': 4567})
skipping: [host2] => (item={'name': 'username4', 'uid': 4567})
PLAY RECAP
********************************************************************
host1 : ok=6 changed=0 unreachable=0 failed=0
host2 : ok=6 changed=0 unreachable=0 failed=0
host3 : ok=6 changed=0 unreachable=0 failed=0
This is shown twice (identical output), once for each play.
Paul
On Thursday, 30 October 2014 09:41:48 UTC+1, Paul Slootman wrote:
>
> Thanks for your example, I'm just about understanding how it works :-) I
> did need to add a .yml extension to the external_vars/groups_users_* files
> but that was obvious from how the playbook referenced those file. Also the
> role needs "group:" and not "groups:" (the error message could have been a
> bit clearer...).
>
> However, when I try this, the gathering facts works fine, then:
>
> TASK: [groups_users | Add groups]
> *********************************************
> fatal: [host1] => with_items expects a list or a set
> fatal: [host2] => with_items expects a list or a set
> fatal: [host3] => with_items expects a list or a set
>
> FATAL: all hosts have already failed -- aborting
>
> This is the sort of thing that's probably trivial to fix with some
> experience but I have no clue how to proceed now :-(
>
> FWIW I'm running:
> ansible 1.8 (devel 44afa7facc) last updated 2014/10/27 14:31:42 (GMT +200)
>
--
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/9c2bb711-0f84-43aa-b072-bd780836639f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.