From 2198c54523adf58fc69ddbea1665ef2be8027cc2 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Fri, 12 Jul 2024 06:21:28 +1000 Subject: [PATCH] membership - Added domain_server option 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. --- changelogs/fragments/membership-server.yml | 4 ++++ plugins/modules/membership.ps1 | 7 +++++++ plugins/modules/membership.py | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 changelogs/fragments/membership-server.yml diff --git a/changelogs/fragments/membership-server.yml b/changelogs/fragments/membership-server.yml new file mode 100644 index 0000000..6e7008a --- /dev/null +++ b/changelogs/fragments/membership-server.yml @@ -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 diff --git a/plugins/modules/membership.ps1 b/plugins/modules/membership.ps1 index 963733a..d993f0a 100644 --- a/plugins/modules/membership.ps1 +++ b/plugins/modules/membership.ps1 @@ -20,6 +20,9 @@ $spec = @{ domain_ou_path = @{ type = 'str' } + domain_server = @{ + type = 'str' + } hostname = @{ type = 'str' } @@ -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 @@ -206,6 +210,9 @@ if ($state -eq 'domain') { if ($domainOUPath) { $joinParams.OUPath = $domainOUPath } + if ($domainServer) { + $joinParams.Server = $domainServer + } try { Add-Computer @joinParams diff --git a/plugins/modules/membership.py b/plugins/modules/membership.py index 87b4c85..9c1cfe9 100644 --- a/plugins/modules/membership.py +++ b/plugins/modules/membership.py @@ -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.