Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

membership - Added domain_server option #134

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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