You can retrieve members of a group using the `getent` module:
http://docs.ansible.com/ansible/getent_module.html

Such as:

- getent: database=group split=':' key=sudo
  register: sudo_users

- debug: var=sudo_users.getent_group.sudo[3]

The output should be a comma separated list.  You could make this an actual
python list using `sudo_users.getent_group.sudo[3].split(',')`


On Wed, May 25, 2016 at 5:00 AM, Marc Roelofs <marc.roel...@springer.com>
wrote:

> I am trying to figure out how to generate a list of users on a remote
> machine who are currently already a member of group A , and append them all
> to group B
> Is this possible ?
>
> Could not find a way to lookup existing users that are already a member of
> a group . I would like to be able to do this on different machines which
> have different users available , so creating a  list of users on my ansible
> management station and using it as input  is not an option
>
> Please advice
>
> Best Marc
>
> --
> 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/30cab7f7-39ca-4591-8024-2863d59a776d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/30cab7f7-39ca-4591-8024-2863d59a776d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v8V68oiAwX21mt9N7VzHkuS3i-uf7SWWTTQWwLiPHJi6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to