ansible-collections/ansible.windows

Allow win_domain_membership to use a specific server

shadowink opened this issue · 1 comments

SUMMARY

win_domain_membership doesn't let you specify a domain controller to use when joining the domain. There are valid reasons for doing that, so it should support it.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_domain_membership

ADDITIONAL INFORMATION

win_domain_membership lets you specify the dns_domain_name of a domain to join but does not let you specify a domain controller to use. In many cases the domain DNS is a load balancer and makes it difficult to use a specific DC. Setting a specific DC is required at times.

Powershell already supports this:
Add-Computer -ComputerName my-vm-name-OUPath "OU=SPECIAL,DC=AD,DC=COMPANY,DC=COM" -DomainName ad.company.com -Credential $domain_join_cred -Server specific-dc.ad.company.com

# Current:
- ansible.windows.win_domain_membership:
    dns_domain_name: ad.company.com
    hostname: my-vm-name
    domain_admin_user: DOMAIN\user
    domain_admin_password: password
    domain_ou_path: "OU=SPECIAL,DC=AD,DC=COMPANY,DC=COM"
    state: domain
  register: domain_state

# Suggested:
- ansible.windows.win_domain_membership:
    dns_domain_name: ad.company.com
    domain_controller_name: specific-dc.ad.company.com
    hostname: my-vm-name
    domain_admin_user: DOMAIN\user
    domain_admin_password: password
    domain_ou_path: "OU=SPECIAL,DC=AD,DC=COMPANY,DC=COM"
    state: domain
  register: domain_state

The win_domain_membership module will soon be deprecated in favour of microsoft.ad.membership. You should submit the feature request over on that collections' repository at https://github.com/ansible-collections/microsoft.ad/tree/main.

I would probably call the option domain_server to match some of the other modules in there that are used to specify the domain controller.