ansible-collections / community.windows

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

win_dns_zone : Add Reverse Lookup zone possibility #519

Open divxdigit opened 1 year ago

divxdigit commented 1 year ago
SUMMARY

Currently the module only allows "Forward Lookup Zones". It would be usefull to allow "Reverse Lookup zones" to the module. This can be done with the parameter NetworkID and optionally the ZoneFile parameter. The add-on would fit perfectly in this current module because it uses the same powershell module to configure it.

ISSUE TYPE
COMPONENT NAME

win_dns_zone

ADDITIONAL INFORMATION
$spec = @{
    options = @{
        name = @{ type = "str"; required = $true }
        type = @{ type = "str"; choices = "primary", "secondary", "forwarder", "stub" }
        replication = @{ type = "str"; choices = "forest", "domain", "legacy", "none" }
        dynamic_update = @{ type = "str"; choices = "secure", "none", "nonsecureandsecure" }
        state = @{ type = "str"; choices = "absent", "present"; default = "present" }
        forwarder_timeout = @{ type = "int" }
        dns_servers = @{ type = "list"; elements = "str" }
        network_id = @{ type = "str" }
        zone_file = @{ type = "str" }
    }
...
$network_id = $module.Params.network_id
$replication = $module.Params.replication
$zone_file = $module.Params.zone_file
...

#To create  a reverse lookup zone 
if ($replication -and $network_id) # variable values need to exist to be parsed
{
  if ($zone_file -like "*in-addr.arpa.dns") 
  {
    #----- Example: Create a file-backed reverse lookup zone -----
    #    This command creates the file-backed reverse lookup zone 0.3.10.in-addr.arpa.
    #PS C:\> Add-DnsServerPrimaryZone -NetworkID 10.3.0.0/24 -ZoneFile "0.3.10.in-addr.arpa.dns"
    Add-DnsServerPrimaryZone -NetworkID $network_id -ReplicationScope $replication -ZoneFile $zone_file
  }
  else
  {
    # ----------- Example 3: Create a reverse lookup zone -----------
    #    This command creates the Active Directory-integrated class C reverse lookup zone 0.1.10.in-addr.arpa with Forest-wide replication scope.
    #  PS C:\> Add-DnsServerPrimaryZone -NetworkID "10.1.0.0/24" -ReplicationScope "Forest"
    #   ZoneName                            ZoneType        IsAutoCreated   IsDsIntegrated  IsReverseLookupZone  IsSigned
    #    --------                            --------        -------------   --------------  -------------------  --------
    #   1.10.in-addr.arpa                   Primary         False           True            True                 False

    Add-DnsServerPrimaryZone -NetworkID $network_id -ReplicationScope $replication
  }
}
else 
{
...
}

#
jp1337 commented 6 months ago

I would like to join the feature. We only have a few forward zones in the Active Directory DNS and significantly more reverse zones. We currently have to make a workaround via PowerShell to create the reverse lookup zones.