hashicorp / terraform-provider-dns

Utility provider that supports DNS updates (RFC 2136) and can optionally be configured with secret key based transaction authentication (RFC 2845).
https://registry.terraform.io/providers/hashicorp/dns/latest
Mozilla Public License 2.0
113 stars 71 forks source link

Unable to create reverse lookup record on a Windows Active Directory server. #141

Open jtn70 opened 3 years ago

jtn70 commented 3 years ago

Provider, Resource and locals used:

provider "dns" {
  update {
    server = "dc.test.com"
    gssapi {
      realm = "TEST.COM"
    }
  }

resource "dns_ptr_record" "rdnsrec" {
  for_each = local.vm_settings
  zone     = "10.in-addr.arpa."
  name     = each.value.ipaddress
  ptr      = "${each.key}.test.com."
}

locals {
  vm_settings = {
    "ubuntutest" = { cpu = 2, memory = 2048, osdisk = 40, datadisk = 0, network = "...", ipaddress = "10.x.x.x", netmask = 24, gateway = "10.x.x.1" },
    ....
}

The error message that is received is: Error: Error updating DNS record: unexpected acceptor flag is not set: expecting a token from the acceptor, not in the initiator │ │ with dns_ptr_record.test, │ on vsphere-ubuntu.tf line 96, in resource "dns_ptr_record" "test": │ 96: resource "dns_ptr_record" "test" {

The corresponding "dns_a_record_set" resource works as expected. I have also tried to create a static resource without using foreach loop with the same result.

The corresponding NSUPDATE command works as expected:

nsupdate
> gsstsig
> update add ubuntutest 300 A 10.x.x.x
> send

Terraform v0.15.4 on linux_amd64

angegar commented 3 years ago

I do not know if it is related, but I have some issues with Active Directory too.

image

It appears the user I used does not exist into the Kerberos DB whereas it was created through the Active Directory interface.

laingsc commented 3 years ago

Get the exact same thing for NS records, A and cname are fine! "expecting a token from the acceptor"

Windows DNS....

SamKirsch10 commented 3 years ago

I am also getting this error for NS records. I ran terraform in TRACE mode and am attaching the logs here. tf_trace_ns_error.log

vars:

ns_records = {
    "redislabs-dev-ob": {
        "target": [
            "d3lredslabss01.cl.local.",
            "d3lredslabss02.cl.local.",
            "d3lredslabss03.cl.local."
        ],
        "zone": "cl.local."
    }
}

records.tf

resource "dns_ns_record_set" "ns_record" {
  for_each = var.ns_records

  zone        = each.value.zone
  name        = each.key
  nameservers = each.value.target
}
verejoel commented 2 years ago

I was able to get PTR records working on Windows AD by creating a dummy resource, then importing a record I created manually. In case it helps, here is my solution:

Example IP address: 10.20.30.40/24 Hostname: centos Domain: example.com Reverse-lookup domain (as shown in AD DNS manager): 30.20.10.in-addr.arpa

Then the following resource block successfully creates the PTR record:

resource "dns_ptr_record" "test" {
  zone = "30.20.10.in-addr.arpa."
  name = "40"
  ptr  = "centos.example.com."
  ttl  = 300
}