Ansible module “vmware_dns_config” incorrectly returns “changed”, even when arguments unchanged.

The Ansible module “vmware_dns_config” will incorrectly return a “changed” condition, even when the arguments are unchanged.

The vmware_dns_config module does run correctly and changes the ESXi DNS settings as needed, but it always reports a “changed” state.

For example:

  • name: Configure DNS for ESXi

vmware_dns_config:

hostname: ‘{{ inventory_hostname }}’

username: ‘{{ vcenter_username }}’

password: ‘{{ vcenter_password }}’

validate_certs: no

We’re not changing the hostname, but it is a required field.

change_hostname_to: ‘{{ inventory_hostname }}’

domainname: mydomain.org

dns_servers:

  • 8.8.8.8

  • 8.8.4.4

delegate_to: localhost

If you run the task a second time, Ansible will report a “changed” state.

Ansible version: 2.7.5 (from CentOS 7.x epel repository)

yum package ansible.noarch 2.6.3-1.el7

Linux: CentOS 7.5.1804

A quick review of the vmware_dns_config.py source code shows that a simple “!=” inequality operator is being used to compare the existing DNS servers data structure to the DNS servers data structure passed as arguments in the task statement. There is no normalization to a “list” structure, for example.

The source code handling of the dns_servers list is very different than the handling of the “ntp_servers” list in the “vmware_host_ntp” module as a comparison, and vmware_host_ntp correctly reports an unchanged status when running the task for a second time with unchanged arguments.