microsoft.ad.computer module – Manage Active Directory computer objects
Note
This module is part of the microsoft.ad collection (version 1.2.0).
You might already have this collection installed if you are using the ansible
package.
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.computer
.
Synopsis
Manages Active Directory computer objects and their attributes.
Requirements
The below requirements are needed on the host that executes this module.
ActiveDirectory
PowerShell module
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: |
|
The principal objects that the current AD object can trust for delegation to either add, remove or set. The values for each sub option must be specified as a distinguished name This is the value set on the This is a highly sensitive attribute as it allows the principals specified to impersonate any account when authenticating with the AD computer object being managed. To clear all principals, use set with an empty list. See Setting list option values for more information on how to add/remove/set list options. |
|
The AD objects by their Any existing principals not specified by add will be untouched unless specified by remove or not in set. |
|
The AD objects by their Any existing pricipals not specified by remove will be untouched unless set is defined. |
|
The AD objects by their This will remove any existing principals if not specified in this list. Specify an empty list to remove all principals allowed to delegate. |
|
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 fully qualified domain name (FQDN) of the computer. This is the value set on the |
|
The password for domain_username. |
|
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. |
|
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. |
|
Choices:
|
|
The identity of the AD object used to find the AD object to manage. 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 managed is selected by the |
|
Specifies the Kerberos encryption types supported the AD computer account. This is the value set on the Avoid using To clear all encryption types, use set with an empty list. See Setting list option values for more information on how to add/remove/set list options. |
|
The encryption types to add to the existing set. Any existing encryption types not specified by add will be untouched unless specified by remove or not in set. Choices:
|
|
The encryption types to remove from the existing set. Any existing encryption types not specified by remove will be untouched unless set is defined. Choices:
|
|
The encryption types to set as the only encryption types allowed by the AD computer. This will remove any existing encryption types if not specified in this list. Specify an empty list to remove all encryption types. Choices:
|
|
Sets the location of the computer account. This is the value set on the |
|
The user or group that manages the object. The value can be in the form of a This is the value set on the |
|
The If identity is specified, and the name of the object it found does not match this value, the object will be renamed. This must be set when state=present or if identity is not set. This is not always going to be the same as the |
|
The path of the OU or the container where the new object should exist in. If no path is specified, the default is the 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. |
|
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:
|
|
The If omitted, the name value is used when creating a new group. It has a maximum of 256 characters, 15 is advised for older operating systems compatibility. If ommitted the value is the same as Note that all computer If |
|
Specifies the service principal name(s) for the account to add, remove or set. This is the value set on the To clear all service principal names, use set with an empty list. See Setting list option values for more information on how to add/remove/set list options. |
|
The SPNs to add to |
|
The SPNs to remove from |
|
The SPNs to set as the only values in This will clear out any existing SPNs if not in the specified list. Set to an empty list to clear all SPNs on the AD object. |
|
Set to Set to The option name must be set when state=present. Using Choices:
|
|
Specifies whether an account is trusted for Kerberos delegation. This is also known as unconstrained Kerberos delegation. This sets the Choices:
|
|
Configures the User Principal Name (UPN) for the account. The format is This is the value set on the |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target |
|
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
See win_domain_computer migration for help on migrating from community.windows.win_domain_computer to this module.
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-Only
are read only values andIs-Single-Value
are attributes with only 1 value.Attempting to set multiple values to a
Is-Single-Value
attribute 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.domain
The official documentation on the microsoft.ad.domain module.
- microsoft.ad.domain_controller
The official documentation on the microsoft.ad.domain_controller module.
- microsoft.ad.membership
The official documentation on the microsoft.ad.membership module.
- microsoft.ad.object_info
The official documentation on the microsoft.ad.object_info module.
- microsoft.ad.object
The official documentation on the microsoft.ad.object module.
- microsoft.ad.offline_join
The official documentation on the microsoft.ad.offline_join module.
- microsoft.ad.group
The official documentation on the microsoft.ad.group module.
- Migration guide
This module replaces
community.windows.win_domain_computer
. See the migration guide for details.- community.windows.win_domain_computer
The official documentation on the community.windows.win_domain_computer module.
Examples
- name: Add linux computer to Active Directory OU using a windows machine
microsoft.ad.computer:
name: one_linux_server
sam_account_name: linux_server$
dns_hostname: one_linux_server.my_org.local
path: OU=servers,DC=my_org,DC=local
description: Example of linux server
enabled: yes
state: present
- name: Remove linux computer from Active Directory using a windows machine
microsoft.ad.computer:
name: one_linux_server
state: absent
- name: Add SPNs to computer
microsoft.ad.computer:
name: TheComputer
spn:
add:
- HOST/TheComputer
- HOST/TheComputer.domain.test
- HOST/TheComputer.domain.test:1234
- name: Remove SPNs on the computer
microsoft.ad.computer:
name: TheComputer
spn:
remove:
- HOST/TheComputer
- HOST/TheComputer.domain.test
- HOST/TheComputer.domain.test:1234
- name: Set the principals the computer trusts for delegation from
microsoft.ad.computer:
name: TheComputer
delegates:
set:
- CN=FileShare,OU=Computers,DC=domain,DC=test
- CN=DC,OU=Domain Controllers,DC=domain,DC=test
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: |
|
The Security Identifier (SID) of the account managed. If a new computer was created in check mode, the SID will be Returned: always Sample: |
Collection links
Issue Tracker Repository (Sources) Report an issue Communication