Skip to content

Commit

Permalink
membership - Added domain_server option
Browse files Browse the repository at this point in the history
Added the option domain_server to the microsoft.ad.membership module.
This option allows the caller to specify the domain controller to use
for domain join operations rather than have Windows lookup the DC for
the domain specified.
  • Loading branch information
jborean93 committed Jul 11, 2024
1 parent 991d812 commit 2198c54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/membership-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
minor_changes:
- >-
microsoft.ad.membership - Added ``domain_server`` option to specify the DC to use for domain join operations -
https://github.com/ansible-collections/microsoft.ad/issues/131#issuecomment-2201151651
7 changes: 7 additions & 0 deletions plugins/modules/membership.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ $spec = @{
domain_ou_path = @{
type = 'str'
}
domain_server = @{
type = 'str'
}
hostname = @{
type = 'str'
}
Expand Down Expand Up @@ -69,6 +72,7 @@ $domainCredential = if ($module.Params.domain_admin_user) {
)
}
$domainOUPath = $module.Params.domain_ou_path
$domainServer = $module.Params.domain_server
$hostname = $module.Params.hostname
$state = $module.Params.state
$workgroupName = $module.Params.workgroup_name
Expand Down Expand Up @@ -206,6 +210,9 @@ if ($state -eq 'domain') {
if ($domainOUPath) {
$joinParams.OUPath = $domainOUPath
}
if ($domainServer) {
$joinParams.Server = $domainServer
}

try {
Add-Computer @joinParams
Expand Down
5 changes: 5 additions & 0 deletions plugins/modules/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
- This is only used when adding the target host to a domain, if it is already a member then it is ignored.
- This cannot be set when I(offline_join_blob) is specified.
type: str
domain_server:
description:
- Specifies the domain controller to use when joining the domain.
type: str
version_added: 1.7.0
hostname:
description:
- The desired hostname for the Windows host.
Expand Down

0 comments on commit 2198c54

Please sign in to comment.