| 1 |
--- |
| 2 |
# Copyright: (c) 2023, Ansible Project |
| 3 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
|
| 5 |
DOCUMENTATION: |
| 6 |
module: computer |
| 7 |
short_description: Manage Active Directory computer objects |
| 8 |
description: |
| 9 |
- Manages Active Directory computer objects and their attributes. |
| 10 |
options: |
| 11 |
delegates: |
| 12 |
description: |
| 13 |
- The principal objects that the current AD object can trust for |
| 14 |
delegation to either add, remove or set. |
| 15 |
- Each subkey value is a list of values in the form of a |
| 16 |
C(distinguishedName), C(objectGUID), C(objectSid), C(sAMAccountName), |
| 17 |
or C(userPrincipalName) string or a dictionary with the I(name) and |
| 18 |
optional I(server) key. |
| 19 |
- This is the value set on the |
| 20 |
C(msDS-AllowedToActOnBehalfOfOtherIdentity) LDAP attribute. |
| 21 |
- This is a highly sensitive attribute as it allows the principals |
| 22 |
specified to impersonate any account when authenticating with the AD |
| 23 |
computer object being managed. |
| 24 |
- To clear all principals, use I(set) with an empty list. |
| 25 |
- See |
| 26 |
R(DN Lookup Attributes,ansible_collections.microsoft.ad.docsite.guide_attributes.dn_lookup_attributes) |
| 27 |
for more information on how DN lookups work. |
| 28 |
- See |
| 29 |
R(Setting list option values,ansible_collections.microsoft.ad.docsite.guide_list_values) |
| 30 |
for more information on how to add/remove/set list options. |
| 31 |
aliases: |
| 32 |
- principals_allowed_to_delegate |
| 33 |
type: dict |
| 34 |
suboptions: |
| 35 |
add: |
| 36 |
description: |
| 37 |
- Adds the principals specified as principals allowed to delegate |
| 38 |
to. |
| 39 |
- Any existing principals not specified by I(add) will be untouched |
| 40 |
unless specified by I(remove) or not in I(set). |
| 41 |
type: list |
| 42 |
elements: raw |
| 43 |
lookup_failure_action: |
| 44 |
description: |
| 45 |
- Control the action to take when the lookup fails to find the DN. |
| 46 |
- C(fail) will cause the task to fail. |
| 47 |
- C(ignore) will ignore the value and continue. |
| 48 |
- C(warn) will ignore the value and display a warning. |
| 49 |
choices: [fail, ignore, warn] |
| 50 |
default: fail |
| 51 |
type: str |
| 52 |
remove: |
| 53 |
description: |
| 54 |
- Removes the principals specified as principals allowed to |
| 55 |
delegate to. |
| 56 |
- Any existing pricipals not specified by I(remove) will be |
| 57 |
untouched unless I(set) is defined. |
| 58 |
type: list |
| 59 |
elements: raw |
| 60 |
set: |
| 61 |
description: |
| 62 |
- Sets the principals specified as principals allowed to delegate |
| 63 |
to. |
| 64 |
- This will remove any existing principals if not specified in this |
| 65 |
list. |
| 66 |
- Specify an empty list to remove all principals allowed to |
| 67 |
delegate. |
| 68 |
type: list |
| 69 |
elements: raw |
| 70 |
dns_hostname: |
| 71 |
description: |
| 72 |
- Specifies the fully qualified domain name (FQDN) of the computer. |
| 73 |
- This is the value set on the C(dNSHostName) LDAP attribute. |
| 74 |
type: str |
| 75 |
do_not_append_dollar_to_sam: |
| 76 |
description: |
| 77 |
- Do not automatically append C($) to the I(sam_account_name) value. |
| 78 |
- This only applies when I(sam_account_name) is explicitly set and can |
| 79 |
be used to create a computer account without the C($) suffix. |
| 80 |
default: false |
| 81 |
type: bool |
| 82 |
version_added: 1.7.0 |
| 83 |
enabled: |
| 84 |
description: |
| 85 |
- C(yes) will enable the computer. |
| 86 |
- C(no) will disable the computer. |
| 87 |
type: bool |
| 88 |
kerberos_encryption_types: |
| 89 |
description: |
| 90 |
- Specifies the Kerberos encryption types supported the AD computer |
| 91 |
account. |
| 92 |
- This is the value set on the C(msDS-SupportedEncryptionTypes) LDAP |
| 93 |
attribute. |
| 94 |
- Avoid using C(rc4) or C(des) as they are older an insecure encryption |
| 95 |
protocols. |
| 96 |
- To clear all encryption types, use I(set) with an empty list. |
| 97 |
- See |
| 98 |
R(Setting list option values,ansible_collections.microsoft.ad.docsite.guide_list_values) |
| 99 |
for more information on how to add/remove/set list options. |
| 100 |
type: dict |
| 101 |
suboptions: |
| 102 |
add: |
| 103 |
description: |
| 104 |
- The encryption types to add to the existing set. |
| 105 |
- Any existing encryption types not specified by I(add) will be |
| 106 |
untouched unless specified by I(remove) or not in I(set). |
| 107 |
choices: |
| 108 |
- aes128 |
| 109 |
- aes256 |
| 110 |
- des |
| 111 |
- rc4 |
| 112 |
type: list |
| 113 |
elements: str |
| 114 |
remove: |
| 115 |
description: |
| 116 |
- The encryption types to remove from the existing set. |
| 117 |
- Any existing encryption types not specified by I(remove) will be |
| 118 |
untouched unless I(set) is defined. |
| 119 |
choices: |
| 120 |
- aes128 |
| 121 |
- aes256 |
| 122 |
- des |
| 123 |
- rc4 |
| 124 |
type: list |
| 125 |
elements: str |
| 126 |
set: |
| 127 |
description: |
| 128 |
- The encryption types to set as the only encryption types allowed |
| 129 |
by the AD computer. |
| 130 |
- This will remove any existing encryption types if not specified |
| 131 |
in this list. |
| 132 |
- Specify an empty list to remove all encryption types. |
| 133 |
choices: |
| 134 |
- aes128 |
| 135 |
- aes256 |
| 136 |
- des |
| 137 |
- rc4 |
| 138 |
type: list |
| 139 |
elements: str |
| 140 |
location: |
| 141 |
description: |
| 142 |
- Sets the location of the computer account. |
| 143 |
- This is the value set on the C(location) LDAP attribute. |
| 144 |
type: str |
| 145 |
managed_by: |
| 146 |
description: |
| 147 |
- The user or group that manages the object. |
| 148 |
- The value can be in the form of a C(distinguishedName), |
| 149 |
C(objectGUID), C(objectSid), C(sAMAccountName), or |
| 150 |
C(userPrincipalName) string or a dictionary with the I(name) and |
| 151 |
optional I(server) key. |
| 152 |
- This is the value set on the C(managedBy) LDAP attribute. |
| 153 |
- See |
| 154 |
R(DN Lookup Attributes,ansible_collections.microsoft.ad.docsite.guide_attributes.dn_lookup_attributes) |
| 155 |
for more information on how DN lookups work. |
| 156 |
type: raw |
| 157 |
sam_account_name: |
| 158 |
description: |
| 159 |
- The C(sAMAccountName) value to set for the computer account. |
| 160 |
- If omitted, the I(name) value is used when creating a new account. |
| 161 |
- It has a maximum of 256 characters, 15 is advised for older operating |
| 162 |
systems compatibility. |
| 163 |
- If ommitted the value is the same as C(name$) when the computer is |
| 164 |
created. |
| 165 |
- Note that all computer C(sAMAccountName) values typically end with a |
| 166 |
C($). |
| 167 |
- By default if C($) is omitted, it will be added to the end. If |
| 168 |
I(do_not_append_dollar_to_sam=True) then the provided value will be |
| 169 |
used as is without adding C($) to the end. |
| 170 |
type: str |
| 171 |
spn: |
| 172 |
description: |
| 173 |
- Specifies the service principal name(s) for the account to add, |
| 174 |
remove or set. |
| 175 |
- This is the value set on the C(servicePrincipalName) LDAP attribute. |
| 176 |
- To clear all service principal names, use I(set) with an empty list. |
| 177 |
- See |
| 178 |
R(Setting list option values,ansible_collections.microsoft.ad.docsite.guide_list_values) |
| 179 |
for more information on how to add/remove/set list options. |
| 180 |
aliases: |
| 181 |
- spns |
| 182 |
type: dict |
| 183 |
suboptions: |
| 184 |
add: |
| 185 |
description: |
| 186 |
- The SPNs to add to C(servicePrincipalName). |
| 187 |
type: list |
| 188 |
elements: str |
| 189 |
remove: |
| 190 |
description: |
| 191 |
- The SPNs to remove from C(servicePrincipalName). |
| 192 |
type: list |
| 193 |
elements: str |
| 194 |
set: |
| 195 |
description: |
| 196 |
- The SPNs to set as the only values in C(servicePrincipalName). |
| 197 |
- This will clear out any existing SPNs if not in the specified |
| 198 |
list. |
| 199 |
- Set to an empty list to clear all SPNs on the AD object. |
| 200 |
type: list |
| 201 |
elements: str |
| 202 |
trusted_for_delegation: |
| 203 |
description: |
| 204 |
- Specifies whether an account is trusted for Kerberos delegation. |
| 205 |
- This is also known as unconstrained Kerberos delegation. |
| 206 |
- This sets the C(ADS_UF_TRUSTED_FOR_DELEGATION) flag in the |
| 207 |
C(userAccountControl) LDAP attribute. |
| 208 |
type: bool |
| 209 |
upn: |
| 210 |
description: |
| 211 |
- Configures the User Principal Name (UPN) for the account. |
| 212 |
- The format is C(<username>@<domain>). |
| 213 |
- This is the value set on the C(userPrincipalName) LDAP attribute. |
| 214 |
type: str |
| 215 |
notes: |
| 216 |
- See |
| 217 |
R(win_domain_computer migration,ansible_collections.microsoft.ad.docsite.guide_migration.migrated_modules.win_domain_computer) |
| 218 |
for help on migrating from M(community.windows.win_domain_computer) to |
| 219 |
this module. |
| 220 |
- This module must be run on a Windows target host with the |
| 221 |
C(ActiveDirectory) module installed. |
| 222 |
- When matching by I(identity) with a C(sAMAccountName) value, the value |
| 223 |
should end with C($). If the provided value does not end with C($) the |
| 224 |
module will still attempt to find the computer account with the provided |
| 225 |
value before attempting a fallback lookup with C($) appended to the end. |
| 226 |
This fallback behaviour was added with version C(1.7.0) of this |
| 227 |
collection. |
| 228 |
extends_documentation_fragment: |
| 229 |
- microsoft.ad.ad_object |
| 230 |
- ansible.builtin.action_common_attributes |
| 231 |
attributes: |
| 232 |
check_mode: |
| 233 |
support: full |
| 234 |
diff_mode: |
| 235 |
support: full |
| 236 |
platform: |
| 237 |
platforms: |
| 238 |
- windows |
| 239 |
seealso: |
| 240 |
- module: microsoft.ad.domain |
| 241 |
- module: microsoft.ad.domain_controller |
| 242 |
- module: microsoft.ad.membership |
| 243 |
- module: microsoft.ad.object_info |
| 244 |
- module: microsoft.ad.object |
| 245 |
- module: microsoft.ad.offline_join |
| 246 |
- module: microsoft.ad.group |
| 247 |
- ref: Migration guide <ansible_collections.microsoft.ad.docsite.guide_migration.migrated_modules.win_domain_computer> |
| 248 |
description: This module replaces C(community.windows.win_domain_computer). See the migration guide for details. |
| 249 |
- module: community.windows.win_domain_computer |
| 250 |
author: |
| 251 |
- Jordan Borean (@jborean93) |
| 252 |
|
| 253 |
EXAMPLES: | |
| 254 |
- name: Add linux computer to Active Directory OU using a windows machine |
| 255 |
microsoft.ad.computer: |
| 256 |
name: one_linux_server |
| 257 |
sam_account_name: linux_server$ |
| 258 |
dns_hostname: one_linux_server.my_org.local |
| 259 |
path: OU=servers,DC=my_org,DC=local |
| 260 |
description: Example of linux server |
| 261 |
enabled: true |
| 262 |
state: present |
| 263 |
|
| 264 |
- name: Remove linux computer from Active Directory using a windows machine |
| 265 |
microsoft.ad.computer: |
| 266 |
identity: one_linux_server$ |
| 267 |
state: absent |
| 268 |
|
| 269 |
- name: Add SPNs to computer |
| 270 |
microsoft.ad.computer: |
| 271 |
identity: TheComputer$ |
| 272 |
spn: |
| 273 |
add: |
| 274 |
- HOST/TheComputer |
| 275 |
- HOST/TheComputer.domain.test |
| 276 |
- HOST/TheComputer.domain.test:1234 |
| 277 |
|
| 278 |
- name: Remove SPNs on the computer |
| 279 |
microsoft.ad.computer: |
| 280 |
identity: TheComputer$ |
| 281 |
spn: |
| 282 |
remove: |
| 283 |
- HOST/TheComputer |
| 284 |
- HOST/TheComputer.domain.test |
| 285 |
- HOST/TheComputer.domain.test:1234 |
| 286 |
|
| 287 |
- name: Set the principals the computer trusts for delegation from |
| 288 |
microsoft.ad.computer: |
| 289 |
identity: TheComputer$ |
| 290 |
delegates: |
| 291 |
set: |
| 292 |
- CN=FileShare,OU=Computers,DC=domain,DC=test |
| 293 |
- OtherServer$ # Lookup by sAMAaccountName |
| 294 |
|
| 295 |
- name: Add computer with sAMAccountName without $ suffix |
| 296 |
microsoft.ad.computer: |
| 297 |
identity: TheComputer |
| 298 |
sam_account_name: TheComputer |
| 299 |
do_not_append_dollar_to_sam: true |
| 300 |
|
| 301 |
RETURN: |
| 302 |
object_guid: |
| 303 |
description: |
| 304 |
- The C(objectGUID) of the AD object that was created, removed, or edited. |
| 305 |
- If a new object was created in check mode, a GUID of 0s will be |
| 306 |
returned. |
| 307 |
returned: always |
| 308 |
type: str |
| 309 |
sample: d84a141f-2b99-4f08-9da0-ed2d26864ba1 |
| 310 |
distinguished_name: |
| 311 |
description: |
| 312 |
- The C(distinguishedName) of the AD object that was created, removed, or |
| 313 |
edited. |
| 314 |
returned: always |
| 315 |
type: str |
| 316 |
sample: CN=MyComputer,CN=Computers,DC=domain,DC=test |
| 317 |
sid: |
| 318 |
description: |
| 319 |
- The Security Identifier (SID) of the account managed. |
| 320 |
- If a new computer was created in check mode, the SID will be |
| 321 |
C(S-1-5-0000). |
| 322 |
returned: always |
| 323 |
type: str |
| 324 |
sample: S-1-5-21-4151808797-3430561092-2843464588-1104 |