google.cloud icon indicating copy to clipboard operation
google.cloud copied to clipboard

gcp_dns_resource_record_set fails to detect changes when removing IPs from DNS A records

Open fedterzi opened this issue 2 months ago • 0 comments

SUMMARY

The gcp_dns_resource_record_set module doesn't properly detect when you're trying to remove IPs from a DNS record. If a record currently has IPs [A, B] and you want to change it to just [B], the module thinks nothing needs to change because B exists in the current list. It only checks if your desired IPs are present, not if extra IPs should be removed.

I think the bug is in _compare_lists() in gcp_utils.py - it only does a one-way check to see if request items exist in the response, but doesn't check the reverse.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

gcp_dns_resource_record_set

ANSIBLE VERSION
ansible [core 2.17.9]
COLLECTION VERSION
google.cloud (1.10.2)
CONFIGURATION
OS / ENVIRONMENT

Running on Debian version 12 (bookworm) Linux

STEPS TO REPRODUCE
  1. Start with a DNS A record that has 2 IPs:

    test.example.com. A 30
    - 192.168.1.10
    - 192.168.1.20
    
  2. Try to update it to just one IP with this playbook:

- name: Update DNS to single IP
  google.cloud.gcp_dns_resource_record_set:
    project: my-gcp-project
    managed_zone:
      name: "my-dns-zone"
      dnsName: "example.com."
    type: A
    name: "test.example.com."
    target:
      - "192.168.1.20"
    ttl: 30
    auth_kind: application
    state: present
EXPECTED RESULTS

Should update the record and remove 192.168.1.10, leaving only 192.168.1.20.

ACTUAL RESULTS

Module says everything's fine:

ok: [localhost]

But the DNS still has both IPs. Nothing changed.

fedterzi avatar Nov 18 '25 22:11 fedterzi