W3cubDocs

/Ansible

win_group_membership - Manage Windows local group membership

New in version 2.4.

Synopsis

  • Allows the addition and removal of local, service and domain users, and domain groups from a local group.

Options

parameter required default choices comments
members
yes
A list of members to ensure are present/absent from the group.
Accepts local users as username, .\username, and SERVERNAME\username.
Accepts domain users and groups as DOMAIN\username and username@DOMAIN.
Accepts service users as NT AUTHORITY\username.
name
yes
Name of the local group to manage membership on.
state
no present
  • present
  • absent
Desired state of the members in the group.

Examples

- name: Add a local and domain user to a local group
  win_group_membership:
    name: Remote Desktop Users
    members:
      - NewLocalAdmin
      - DOMAIN\TestUser
    state: present

- name: Remove a domain group and service user from a local group
  win_group_membership:
    name: Backup Operators
    members:
      - DOMAIN\TestGroup
      - NT AUTHORITY\SYSTEM
    state: absent

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
members
A list of all local group members at completion; this is empty if the group contains no members.
success list ['DOMAIN\\TestUser', 'NewLocalAdmin']
removed
A list of members removed when state is absent; this is empty if no members are removed.
success and C(state) is C(absent) list ['DOMAIN\\TestGroup', 'NT AUTHORITY\\SYSTEM']
name
The name of the target local group.
always string Administrators
added
A list of members added when state is present; this is empty if no members are added.
success and C(state) is C(present) list ['NewLocalAdmin', 'DOMAIN\\TestUser']

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_group_membership_module.html