2017-07-31 18:10:57 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-02-25 02:09:54 +00:00
|
|
|
# Copyright: (c) 2017, Andrew Saraceni <andrew.saraceni@gmail.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2017-07-31 18:10:57 +00:00
|
|
|
|
2017-08-16 03:16:38 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
2017-07-31 18:10:57 +00:00
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
2017-08-02 02:06:39 +00:00
|
|
|
module: win_group_membership
|
2017-07-31 18:10:57 +00:00
|
|
|
version_added: "2.4"
|
|
|
|
short_description: Manage Windows local group membership
|
|
|
|
description:
|
|
|
|
- Allows the addition and removal of local, service and domain users,
|
|
|
|
and domain groups from a local group.
|
|
|
|
options:
|
|
|
|
name:
|
|
|
|
description:
|
|
|
|
- Name of the local group to manage membership on.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2018-02-25 02:09:54 +00:00
|
|
|
required: yes
|
2017-07-31 18:10:57 +00:00
|
|
|
members:
|
|
|
|
description:
|
|
|
|
- A list of members to ensure are present/absent from the group.
|
2018-06-27 00:54:27 +00:00
|
|
|
- Accepts local users as .\username, and SERVERNAME\username.
|
2017-07-31 18:10:57 +00:00
|
|
|
- Accepts domain users and groups as DOMAIN\username and username@DOMAIN.
|
|
|
|
- Accepts service users as NT AUTHORITY\username.
|
2018-06-27 00:54:27 +00:00
|
|
|
- Accepts all local, domain and service user types as username,
|
|
|
|
favoring domain lookups when in a domain.
|
2018-07-17 21:29:05 +00:00
|
|
|
type: list
|
2019-01-03 16:50:44 +00:00
|
|
|
required: yes
|
2017-07-31 18:10:57 +00:00
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- Desired state of the members in the group.
|
2019-01-31 01:48:49 +00:00
|
|
|
- C(pure) was added in Ansible 2.8.
|
|
|
|
- When C(state) is C(pure), only the members specified will exist,
|
|
|
|
and all other existing members not specified are removed.
|
2019-01-03 16:50:44 +00:00
|
|
|
type: str
|
2019-01-31 01:48:49 +00:00
|
|
|
choices: [ absent, present, pure ]
|
2017-07-31 18:10:57 +00:00
|
|
|
default: present
|
2018-12-15 02:23:59 +00:00
|
|
|
seealso:
|
|
|
|
- module: win_domain_group
|
|
|
|
- module: win_domain_membership
|
|
|
|
- module: win_group
|
2017-07-31 18:10:57 +00:00
|
|
|
author:
|
|
|
|
- Andrew Saraceni (@andrewsaraceni)
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: Add a local and domain user to a local group
|
2017-08-02 02:06:39 +00:00
|
|
|
win_group_membership:
|
2017-07-31 18:10:57 +00:00
|
|
|
name: Remote Desktop Users
|
|
|
|
members:
|
|
|
|
- NewLocalAdmin
|
|
|
|
- DOMAIN\TestUser
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Remove a domain group and service user from a local group
|
2017-08-02 02:06:39 +00:00
|
|
|
win_group_membership:
|
2017-07-31 18:10:57 +00:00
|
|
|
name: Backup Operators
|
|
|
|
members:
|
|
|
|
- DOMAIN\TestGroup
|
|
|
|
- NT AUTHORITY\SYSTEM
|
|
|
|
state: absent
|
2019-01-31 01:48:49 +00:00
|
|
|
|
|
|
|
- name: Ensure only a domain user exists in a local group
|
|
|
|
win_group_membership:
|
|
|
|
name: Remote Desktop Users
|
|
|
|
members:
|
|
|
|
- DOMAIN\TestUser
|
|
|
|
state: pure
|
2017-07-31 18:10:57 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = r'''
|
|
|
|
name:
|
|
|
|
description: The name of the target local group.
|
|
|
|
returned: always
|
2018-12-18 21:25:30 +00:00
|
|
|
type: str
|
2017-07-31 18:10:57 +00:00
|
|
|
sample: Administrators
|
|
|
|
added:
|
2019-01-31 01:48:49 +00:00
|
|
|
description: A list of members added when C(state) is C(present) or
|
|
|
|
C(pure); this is empty if no members are added.
|
2017-07-31 18:10:57 +00:00
|
|
|
returned: success and C(state) is C(present)
|
|
|
|
type: list
|
2018-06-27 00:54:27 +00:00
|
|
|
sample: ["SERVERNAME\\NewLocalAdmin", "DOMAIN\\TestUser"]
|
2017-07-31 18:10:57 +00:00
|
|
|
removed:
|
2019-01-31 01:48:49 +00:00
|
|
|
description: A list of members removed when C(state) is C(absent) or
|
|
|
|
C(pure); this is empty if no members are removed.
|
2017-07-31 18:10:57 +00:00
|
|
|
returned: success and C(state) is C(absent)
|
|
|
|
type: list
|
|
|
|
sample: ["DOMAIN\\TestGroup", "NT AUTHORITY\\SYSTEM"]
|
|
|
|
members:
|
|
|
|
description: A list of all local group members at completion; this is empty
|
|
|
|
if the group contains no members.
|
|
|
|
returned: success
|
|
|
|
type: list
|
2018-06-27 00:54:27 +00:00
|
|
|
sample: ["DOMAIN\\TestUser", "SERVERNAME\\NewLocalAdmin"]
|
2017-07-31 18:10:57 +00:00
|
|
|
'''
|