Re: [ansible-project] Create user on host if is in specific group

36 views
Skip to first unread message

Michael DeHaan

unread,
Dec 15, 2014, 7:04:41 AM12/15/14
to ansible...@googlegroups.com
Looks like you may want:

when: users_group[0] in item.groups

You may also just wish to change this:

users_group: admin




On Sun, Dec 14, 2014 at 10:13 AM, Werner Dijkerman <wern...@gmail.com> wrote:
Hi there,

I'm busy with an module for managing users (With public keys) for my work. 

I've got the following vars:

users:
 - name: "Werner Dijkerman"
   state: present
   uid: 1000
   gid: 1000
   groups: 
     - admin
     - simple_group

users_group:
 - admin

And I have the following task:

 - name: Check users state
   user: name="{{ item.name }}"
         state="{{ item.state }}"
   with_items: "{{ users }}"
   when: users_group in item.groups

When I add the users_group var in an host_group var file (Like group_vars/all), the users in that specific group needs te be created on the host.

But when I run the playbook, it keeps "skipping".

What am I missing or doing wrong? I tried to use it with "with_subelements" but it still keep "skipping" 

Kind regards,

Werner

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/172fcef0-8b37-4366-94ca-7a72b70d3658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Werner Dijkerman

unread,
Dec 15, 2014, 7:38:39 AM12/15/14
to ansible...@googlegroups.com
Hello Michael

Thanks for your answer. 

users_group:
 - admin

I did it this way, because for some hosts (like development) the development guys needs to login to. So it would be like this:
users_group:
 - admin
 - development

Bit I will check this out!

Kind regards,
Werner

Op maandag 15 december 2014 13:04:41 UTC+1 schreef Michael DeHaan:

Werner Dijkerman

unread,
Dec 15, 2014, 2:16:14 PM12/15/14
to ansible...@googlegroups.com
Michael,

It works perfect! Thanks!


Op maandag 15 december 2014 13:04:41 UTC+1 schreef Michael DeHaan:
Looks like you may want:
Reply all
Reply to author
Forward
0 new messages