# WIN\_DNS\_Record

**URL:** <https://forum.ansible.com/t/win-dns-record/35738>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [September 14, 2021, 3:24pm UTC](https://forum.ansible.com/t/win-dns-record/35738 "2021-09-14T15:24:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzersatz](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@kzersatz](https://forum.ansible.com/u/kzersatz)\
**Post date:** [September 14, 2021, 3:24pm UTC](https://forum.ansible.com/t/win-dns-record/35738/1 "2021-09-14T15:24:48Z")

</div>

Alrighty

So I’m behind the curve and am updating all of my collections and testing out playbooks here and there, and I noticed along the way that from between community.windows 1.1.0 to 1.6.0 that there has been a major change to how this module is handling computer\_name:

Namely, right before I updated it, I tested the playbook and it ran without incident.  
immediately after, I ran it, and failures abound.

Using module file /root/.ansible/collections/ansible\_collections/community/windows/plugins/modules/win\_dns\_record.ps1  
Pipelining is enabled.  
\< Windows\_ansible\_host.DOMAIN.net \> ESTABLISH WINRM CONNECTION FOR USER: [SA\_REDACTED\_Domain@DOMAIN.NET](mailto:SA_REDACTED_Domain@DOMAIN.NET) on PORT 5986 TO [l1pnchwmgt12.columbuschildrens.net](http://l1pnchwmgt12.columbuschildrens.net)  
EXEC (via pipeline wrapper)  
ok: [Windows\_ansible\_host.DOMAIN.net] =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“computer\_name”: “[DNSserverredacted.DOMAIN.net](http://DNSserverredacted.DOMAIN.net)”,  
“name”: “deleteme”,  
“port”: null,  
“priority”: null,  
“state”: “present”,  
“ttl”: 3600,  
“type”: “A”,  
“value”: [  
“10.60.24.121”  
],  
“weight”: null,  
“zone”: “[DOMAIN.net](http://DOMAIN.net)”  
}  
}  
}

The above are the results for what worked in 1.1.0.

Immediately after update, it appears that the Computer\_name: field is being entirely ignored and this module is trying to process the request locally, seeing as my ansible node isn’t a DNS server, domain controller, or anything special, its failing every time with a complete inability to find the DNS Zone, duh.

The full traceback is:  
Failed to get the zone information for [DOMAIN.net](http://DOMAIN.net) on server Windows\_ansible\_host.  
At line:73 char:12

- $records = Get-DnsServerResourceRecord -ZoneName $zone -Name $name -R …
- 

```auto

```

- CategoryInfo : NotSpecified: ([columbuschildrens.net](http://columbuschildrens.net):root/Microsoft/…rResourceRecord) [Get-DnsServerResourceRecord], CimException
- FullyQualifiedErrorId : WIN32 1722,Get-DnsServerResourceRecord

ScriptStackTrace:  
at Get-DnsServerResourceRecord, : line 3130  
at , : line 73

Microsoft.Management.Infrastructure.CimException: Failed to get the zone information for [DOMAIN.net](http://DOMAIN.net) on server Windows\_ansible\_host.DOMAIN.

Am I mishandling something here?

I’ve attempted FQDN, NetBios name and IP addr for computer\_name, and nothing is successful.  
it is a VERY simplistic playbook for simply testing the module that it will work.  
I can post it if necessary.

Thanks  
Jess

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 14, 2021, 3:39pm UTC](https://forum.ansible.com/t/win-dns-record/35738/2 "2021-09-14T15:39:09Z")

</div>

That issue appears to have been fixed in the collection, but the change has not been included in a release yet:

[https://github.com/ansible-collections/community.windows/pull/277](https://github.com/ansible-collections/community.windows/pull/277)

---

<div class="post-metadata">

**Author:** ![kzersatz](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@kzersatz](https://forum.ansible.com/u/kzersatz)\
**Post date:** [September 15, 2021, 1:00pm UTC](https://forum.ansible.com/t/win-dns-record/35738/3 "2021-09-15T13:00:01Z")

</div>

Welp, time to integrate that myself.

Thanks for the assist Matt.

---

<div class="post-metadata">

**Author:** ![Chris\_Nicel](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Nicel](https://forum.ansible.com/u/Chris_Nicel)\
**Post date:** [October 4, 2021, 1:15pm UTC](https://forum.ansible.com/t/win-dns-record/35738/4 "2021-10-04T13:15:55Z")

</div>

Howdy,

I am also seeing this issue.

chris:~/git/ansible$ ansible -m community.windows.win\_dns\_record -a “type=CNAME computer\_name=‘dc1.example.local’ name=myapp zone=‘[internal.example.co.uk](http://internal.example.co.uk)’ ttl=60 value=‘docker1.example.local’” -i inventory/test.yml admgmthost -vvv  
ansible [core 2.11.5]  
config file = /home/chris/git/ansible/ansible.cfg  
configured module search path = [‘/home/chris/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /home/chris/git/.venv/lib/python3.8/site-packages/ansible  
ansible collection location = /home/chris/git/ansible/installed\_collections  
executable location = /home/chris/git/.venv/bin/ansible  
python version = 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0]  
jinja version = 3.0.1  
libyaml = True  
Using /home/chris/git/ansible/ansible.cfg as config file  
host\_list declined parsing /home/chris/git/ansible/inventory/test.yml as it did not pass its verify\_file() method  
script declined parsing /home/chris/git/ansible/inventory/test.yml as it did not pass its verify\_file() method  
Parsed /home/chris/git/ansible/inventory/test.yml inventory source with yaml plugin  
Skipping callback ‘default’, as we already have a stdout callback.  
Skipping callback ‘minimal’, as we already have a stdout callback.  
Skipping callback ‘oneline’, as we already have a stdout callback.  
META: ran handlers  
Using module file /home/chris/git/.venv/lib/python3.8/site-packages/ansible\_collections/community/windows/plugins/modules/win\_dns\_record.ps1  
Pipelining is enabled.  
\<admgmthost.example.local\> ESTABLISH WINRM CONNECTION FOR USER: example\service.ansible on PORT 5985 TO admgmthost.example.local  
EXEC (via pipeline wrapper)  
The full traceback is:  
Failed to get the zone information for [internal.example.co.uk](http://internal.example.co.uk) on server admgmthost.  
At line:73 char:12

- $records = Get-DnsServerResourceRecord -ZoneName $zone -Name $name -R …
- 

```auto

```

- CategoryInfo : NotSpecified: ([internal.example.co.uk](http://internal.example.co.uk):root/Microsoft/…rResourceRecord) [Get-DnsServerResourceRecord], CimException
- FullyQualifiedErrorId : WIN32 1722,Get-DnsServerResourceRecord

ScriptStackTrace:  
at Get-DnsServerResourceRecord, : line 4075  
at , : line 73

Microsoft.Management.Infrastructure.CimException: Failed to get the zone information for [internal.example.co.uk](http://internal.example.co.uk) on server admgmthost.  
at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.ProcessNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)  
admgmthost | FAILED! =\> {  
“changed”: false,  
“msg”: “Unhandled exception while executing module: Failed to get the zone information for [internal.example.co.uk](http://internal.example.co.uk) on server admgmthost.”  
}

I have verified that the ps1 file looks correct located at: /home/chris/git/.venv/lib/python3.8/site-packages/ansible\_collections/community/windows/plugins/modules/win\_dns\_record.ps1  
(It appears to have the changes in the above-mentioned PR: [https://github.com/ansible-collections/community.windows/pull/277](https://github.com/ansible-collections/community.windows/pull/277))

Installed 1.7.0 of the ansible.windows collection.

Re-created the Get-DNSServerResourceRecord command used here and ran on a windows machine via winrm to the same admgmthost server with no issue. Also ran find on the host machine logged in as the service.ansible user. Interestingly, if I omit the -ComputerName switch in the powershell replicas I get the same response. However, it appears as though the variables are being set correctly in the win\_dns\_record.ps1 file… unless I missed something 🙂

Any thoughts?

Cheers

Chris

---

<div class="post-metadata">

**Author:** ![Chris\_Nicel](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Nicel](https://forum.ansible.com/u/Chris_Nicel)\
**Post date:** [October 4, 2021, 1:18pm UTC](https://forum.ansible.com/t/win-dns-record/35738/5 "2021-10-04T13:18:00Z")

</div>

I should add that we’ve been using this in various playbooks for a while now. It mysteriously stopped working some time between the 9th of August and the 21st of September. Although, that is quite dependant on when our ansible build process ran and picked up new dependency versions.

Cheers

Chris

---

<div class="post-metadata">

**Author:** ![Chris\_Nicel](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Nicel](https://forum.ansible.com/u/Chris_Nicel)\
**Post date:** [October 4, 2021, 1:56pm UTC](https://forum.ansible.com/t/win-dns-record/35738/6 "2021-10-04T13:56:41Z")

</div>

Ok, after finding the last version of my ansible container that worked and digging around in the galaxy collection versions. I managed to fix it by installing the collection community.windows at version 1.5.0,

This should keep me going for now 🙂 Although I’m interested to know if I can help troubleshoot the issue (or indeed if a newer version will also work)

Cheers

Chris
