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.