Skip to content

win_dns_zone doesn't detect changes in check mode #793

@v1adev

Description

@v1adev
SUMMARY

When the win_dns_zone is executed in check mode (with or without diff) it doesn't detect changes to DNS zone settings (i.e. changing the forwarder_timeout or dns_servers). Applying the changes works properly and the number of changes are then reported correctly, including diffs. This makes it difficult to check for drift since the changes and diffs can only be seen after the fact.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible.windows.win_dns_zone

ANSIBLE VERSION
ansible [core 2.18.6]
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.local/bin/ansible
  python version = 3.12.10 (main, Apr 29 2025, 00:24:12) [GCC 10.2.1 20210110] (/usr/local/bin/python3.12)
  jinja version = 3.1.6
  libyaml = True
COLLECTION VERSION
Collection      Version
--------------- -------
ansible.windows 2.8.0
CONFIGURATION
CONFIG_FILE() = None

GALAXY_SERVERS:
OS / ENVIRONMENT

Running in a Visual Studio Code Dev Container using the mcr.microsoft.com/devcontainers/python:1-3.12-bullseye base image.

STEPS TO REPRODUCE

Run the playbook below to create the conditional forwarder zone or use an existing one. Change one of the parameter values, like forwarder_timeout or dns_servers to be different from the "live" version. Run the playbook in check mode (with or without diff) and observe that no changes are reported. Remove the check mode flag and run the playbook again. Observe that the changes have been made to make the "live" version match the config.

---
- name: Update DNS servers
  hosts: dnsservers

  tasks:
    - name: Add conditional forwarder
      ansible.windows.win_dns_zone:
        name: privatelink.grafana.azure.com
        type: forwarder
        replication: none
        forwarder_timeout: 5
        state: present
        dns_servers:
          - 10.0.0.10
EXPECTED RESULTS

Expect changed=1 in the example above

ACTUAL RESULTS
PLAY [Update DNS servers] *****************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************
ok: [DNS1]

TASK [Add conditional forwarder] **********************************************************************************************************************************************************************************************
ok: [DNS1]

PLAY RECAP ********************************************************************************************************************************************************************************************************************
DNS1  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions