Creates, modifies or removes domain groups
- Creates, modifies or removes groups in Active Directory.
- For local groups, use the :ref:`ansible.windows.win_group <ansible.windows.win_group_module>` module instead.
Note
- This must be run on a host that has the ActiveDirectory powershell module installed.
.. seealso:: :ref:`ansible.windows.win_domain_module` The official documentation on the **ansible.windows.win_domain** module. :ref:`ansible.windows.win_domain_controller_module` The official documentation on the **ansible.windows.win_domain_controller** module. :ref:`community.windows.win_domain_computer_module` The official documentation on the **community.windows.win_domain_computer** module. :ref:`ansible.windows.win_domain_membership_module` The official documentation on the **ansible.windows.win_domain_membership** module. :ref:`community.windows.win_domain_user_module` The official documentation on the **community.windows.win_domain_user** module. :ref:`ansible.windows.win_group_module` The official documentation on the **ansible.windows.win_group** module. :ref:`ansible.windows.win_group_membership_module` The official documentation on the **ansible.windows.win_group_membership** module.
- name: Ensure the group Cow exists using sAMAccountName
community.windows.win_domain_group:
name: Cow
scope: global
path: OU=groups,DC=ansible,DC=local
- name: Ensure the group Cow doesn't exist using the Distinguished Name
community.windows.win_domain_group:
name: CN=Cow,OU=groups,DC=ansible,DC=local
state: absent
- name: Delete group ignoring the protection flag
community.windows.win_domain_group:
name: Cow
state: absent
ignore_protection: yes
- name: Create group with delete protection enabled and custom attributes
community.windows.win_domain_group:
name: Ansible Users
scope: domainlocal
category: security
attributes:
mail: [email protected]
wWWHomePage: www.ansible.com
ignore_protection: yes
- name: Change the OU of a group using the SID and ignore the protection flag
community.windows.win_domain_group:
name: S-1-5-21-2171456218-3732823212-122182344-1189
scope: global
organizational_unit: OU=groups,DC=ansible,DC=local
ignore_protection: yes
- name: Add managed_by user
community.windows.win_domain_group:
name: Group Name Here
managed_by: Domain Admins
- name: Add group and specify the AD domain services to use for the create
community.windows.win_domain_group:
name: Test Group
domain_username: [email protected]
domain_password: Password01!
domain_server: corp-DC12.corp.ansible.com
scope: domainlocal
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
attributes
dictionary
|
group exists and attributes are set on the module invocation |
Custom attributes that were set by the module. This does not show all the custom attributes rather just the ones that were set by the module.
Sample:
{'mail': '[email protected]', 'wWWHomePage': 'www.ansible.com'}
|
canonical_name
string
|
group exists |
The canonical name of the group.
Sample:
ansible.local/groups/Cow
|
category
string
|
group exists |
The Group type value of the group, i.e. Security or Distribution.
Sample:
Security
|
created
boolean
|
always |
Whether a group was created
Sample:
True
|
description
string
|
group exists |
The Description of the group.
Sample:
Group Description
|
display_name
string
|
group exists |
The Display name of the group.
Sample:
Users who connect through RDP
|
distinguished_name
string
|
group exists |
The full Distinguished Name of the group.
Sample:
CN=Cow,OU=groups,DC=ansible,DC=local
|
group_scope
string
|
group exists |
The Group scope value of the group.
Sample:
Universal
|
guid
string
|
group exists |
The guid of the group.
Sample:
512a9adb-3fc0-4a26-9df0-e6ea1740cf45
|
managed_by
string
|
group exists |
The full Distinguished Name of the AD object that is set on the managedBy attribute.
Sample:
CN=Domain Admins,CN=Users,DC=ansible,DC=local
|
name
string
|
group exists |
The name of the group.
Sample:
Cow
|
protected_from_accidental_deletion
boolean
|
group exists |
Whether the group is protected from accidental deletion.
Sample:
True
|
sid
string
|
group exists |
The Security ID of the group.
Sample:
S-1-5-21-2171456218-3732823212-122182344-1189
|
- Jordan Borean (@jborean93)