microsoft.ad.site module – Manage Active Directory replication sites
Note
This module is part of the microsoft.ad collection (version 1.11.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install microsoft.ad.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: microsoft.ad.site.
New in microsoft.ad 1.11.0
Synopsis
Create, modify, or remove Active Directory replication sites.
Sites are used to control replication traffic and help clients discover nearby network resources such as domain controllers.
Requirements
The below requirements are needed on the host that executes this module.
ActiveDirectoryPowerShell moduleWhen targeting PowerShell 7, Windows Server 2022/Windows 10 build 1903 or later is required.
Parameters
Parameter |
Comments |
|---|---|
The attributes to either add, remove, or set on the AD object. The value of each attribute option should be a dictionary where the key is the LDAP attribute, e.g. The attribute value(s) can either be the raw string, integer, or bool value to add, remove, or set on the attribute in question. The value can also be a dictionary with the type key set to The The The The String attribute values are compared using a case sensitive match on the AD object being managed. See LDAP attributes help for more information. Default: |
|
A dictionary of all the attributes and their value(s) to add to the AD object being managed if they are not already present. This is used for attributes that can contain multiple values, if the attribute only allows a single value, use set instead. Default: |
|
A dictionary of all the attributes and their value(s) to remove from the AD object being managed if they are present. This is used for attributes that can contain multiple values, if the attribute only allows a single value, use set instead. Default: |
|
A dictionary of all attributes and their value(s) to set on the AD object being managed. This will replace any existing values if they do not match the ones being requested. The order of attribute values are not checked only, only that the values requested are the only values on the object attribute. Set this to null or an empty list to clear any values for the attribute. Default: |
|
Whether the KCC inter-site topology generator (ISTG) creates connections for inter-site replication automatically. Set to Choices:
|
|
Whether the KCC generates intra-site replication connections automatically. Set to Choices:
|
|
The description of the AD object to set. This is the value set on the |
|
The display name of the AD object to set. This is the value of the |
|
Specifies the credentials that should be used when using the server specified by name. To specify credentials for the default domain server, use an entry without the name key or use the domain_username and domain_password option. This can be set under the play’s module defaults under the See AD authentication in modules for more information. Default: |
|
The name of the server these credentials are for. This value should correspond to the value used in other options that specify a custom server to use, for example an option that references an AD identity located on a different AD server. This key can be omitted in one entry to specify the default credentials to use when a server is not specified instead of using domain_username and domain_password. |
|
The password to use when connecting to the server specified by name. |
|
The username to use when connecting to the server specified by name. |
|
The password for domain_username. The domain_credentials sub entry without a name key can also be used to specify the credentials for the default domain authentication. This can be set under the play’s module defaults under the |
|
Specified the Active Directory Domain Services instance to connect to. Can be in the form of an FQDN or NetBIOS name. If not specified then the value is based on the default domain of the computer running PowerShell. Custom credentials can be specified under a domain_credentials entry without a name key or through domain_username and domain_password. This can be set under the play’s module defaults under the |
|
The username to use when interacting with AD. If this is not set then the user that is used for authentication will be the connection user. Ansible will be unable to use the connection user unless auth is Kerberos with credential delegation or CredSSP, or become is used on the task. The domain_credentials sub entry without a name key can also be used to specify the credentials for the default domain authentication. This can be set under the play’s module defaults under the |
|
The identity of the AD object used to find the AD object to manage. This must be specified if; name is not set, when trying to rename the object with a new name, or when trying to move the object into a different path. The identity can be in the form of a GUID representing the If omitted, the AD object to manage is selected by the When using the microsoft.ad.computer module, the identity will automatically append |
|
The user or group that manages the object. The value can be in the form of a This is the value set on the See DN Lookup Attributes for more information on how DN lookups work. |
|
The If identity is specified, and the name of the object found by that identity does not match this value, the object will be renamed. This must be specified if identity is not set. |
|
The path of the OU or the container where the new object should exist in. If creating a new object, the new object will be created at the path specified. If no path is specified then the If managing an existing object found by identity, the path of the found object will be moved to the one specified by this option. If no path is specified, the object will not be moved. The modules microsoft.ad.computer, microsoft.ad.user, and microsoft.ad.group have their own default path that is configured on the Active Directory domain controller. This can be set to the literal value |
|
Marks the object as protected from accidental deletion. This applies a deny access right from deleting the object normally and the protection needs to be removed before the object can be deleted through the GUI or any other tool outside Ansible. Using state=absent will still delete the AD object even if it is marked as protected from deletion. Choices:
|
|
Set to Set to The option name must be set when state=present. Using Choices:
|
|
Whether Universal Group Membership Caching (UGMC) is enabled for the site. Useful in branch-office sites without a Global Catalog server to reduce authentication latency. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped. |
|
Support: full |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platform: windows |
Target OS/families that can be operated against |
Notes
Note
The path option for sites defaults to the
CN=Sites,CN=Configuration,...container. Sites cannot be moved to a different container.This module must be run on a Windows target host with the
ActiveDirectorymodule installed.Some LDAP attributes can have only a single value set while others can have multiple. Some attributes are also read only and cannot be changed. It is recommended to look at the schema metadata for an attribute where
System-Onlyare read only values andIs-Single-Valueare attributes with only 1 value.Attempting to set multiple values to a
Is-Single-Valueattribute results in undefined behaviour.If running on a server that is not a Domain Controller, credential delegation through CredSSP or Kerberos with delegation must be used or the domain_username, domain_password must be set.
See Also
See also
- microsoft.ad.object_info
Gather information an Active Directory object.
Examples
- name: Create a replication site for the London branch office
microsoft.ad.site:
name: London-Branch
description: London branch office site
state: present
- name: Create a site with deletion protection
microsoft.ad.site:
name: NYC-HQ
description: New York City headquarters
protect_from_deletion: true
state: present
- name: Enable Universal Group Caching on a branch site
microsoft.ad.site:
name: London-Branch
universal_group_caching_enabled: true
state: present
- name: Disable automatic inter-site topology generation
microsoft.ad.site:
name: London-Branch
automatic_inter_site_topology_generation_enabled: false
state: present
- name: Set managedBy using an identity from another DC
microsoft.ad.site:
name: London-Branch
managed_by:
name: manager-user
server: OtherDC
- name: Remove a replication site
microsoft.ad.site:
name: London-Branch
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The Returned: always Sample: |
|
The If a new object was created in check mode, a GUID of 0s will be returned. Returned: always Sample: |