ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
204 stars 158 forks source link

win_dns_zone - Support computer_name like in win_dns_record #273

Open laingsc opened 3 years ago

laingsc commented 3 years ago
SUMMARY

win_dns_zone - Support computer_name similar to win_dns_record

ISSUE TYPE
COMPONENT NAME

win_dns_zone

ADDITIONAL INFORMATION

In this use-case, we're using Azure AD DS (Windows Domain Servers) as a Service, and you cannot connect to them since they're as a Service. I pass this to Ansible Tower using Variables, and my current workaround is as below:

# Use PowerShell to create DNS Zone. win_dns_zone module doesn't support ComputerName
  - name: Create DNS forwarder
    block:
      - name: Add forwarding zone
        win_command: powershell.exe - 
        args:
          stdin: >
            Add-DnsServerConditionalForwarderZone
            -ComputerName "{{ adds_dns_computer_name }}"
            -Name "{{ adds_dns_name }}"
            -MasterServers {{ forward_dns_servers }}
            -ReplicationScope "Domain"
    rescue:
      - name: Change existing forwarding zone
        win_command: powershell.exe - 
        args:
          stdin: >
            Set-DnsServerConditionalForwarderZone
            -ComputerName "{{ adds_dns_computer_name }}"
            -Name "{{ adds_dns_name }}"
            -MasterServers {{ forward_dns_servers }}
    when:
      - adds_dns_type == "forwarder"

 The following works perfectly for this use-case:

  tasks: 
  - name: Set DNS Record
    win_dns_record:
      computer_name: "{{ adds_dns_computer_name }}"
      name: "{{ adds_dns_name }}"
      type: "{{ adds_dns_type }}"
      value: "{{ adds_dns_value | default(omit) }}"
      state: "{{ adds_dns_state }}"
      zone: "{{ adds_dns_zone }}"
    when: >
      adds_dns_type == "A" or
      adds_dns_type == "AAAA" or
      adds_dns_type == "CNAME" or
      adds_dns_type == "PTR" or
      adds_dns_type == "NS"
caidingyu commented 2 years ago

I'm using AWS AD service and facing the same issue. If win_dns_zone could support ComputerName option, as natively supported by PowerShell that would be appreciated.

git-cgallagher commented 1 year ago

@laingsc , @caidingyu This seems to be a recuring theme with _aaS offerings. FSX for Windows and AWS ADDS also comes to mind. As a potential stop gap can you install RSAT-DNS on a management server and run the tasks against that host instead?

caidingyu commented 1 year ago

Sorry, it's not a feasible solution in our case. We intend to use managed service (AWS managed AD) and avoid manual managment of additional DNS nodes.