0

I try to update serial number for a zone in Private DNS in Azure. To do that, I run Ansible code:

- name: Increment DNS serial
  azure_rm_dnsrecordset:
    resource_group: "{{ my_rg }}"
    zone_name: "{{ my_domain }}"
    relative_name: "@"
    record_type: "SOA"
    records:
      - serial_number: "{{ new_serial }}"
  register: dns_update
  until: dns_update is succeeded      

Ansible however fails with type mismatch error:

The full traceback is:
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            ...
            "record_mode": "purge",
            "record_type": "SOA",
            "records": [
                {
                    "serial_number": "2"
                }
            ],
            "relative_name": "@",
            "resource_group": "my-rg",
            "state": "present",
            ...
        }
    },
    "msg": "implementation error: unknown type long requested for serial_number"
}

The error message is a bit confusing: should I understand it as Ansible trying to send 2 as long while Azure API expects string, or vice versa, Azure expects long but Ansible sends string?

Which type conversion should I apply?

Except above issue, is this proper way to update serial?

Dmytro
  • 216
  • 1
  • 4
  • 14
  • Try parsing your variable as below - serial_number: "{{ new_serial | int }}" – gary lopez Nov 03 '20 at 23:35
  • Thank you, but this does not change anything. I suppose that API is hardcoded to accept int values here, so I have to send int, not string. But it's obvious that whatever I write as "{{ any expression}}" is a string. – Dmytro Nov 04 '20 at 15:17

1 Answers1

0

I bypassed this by switching from azure_rm_dnsrecordset Ansible module to az call, replacing the template as below:

- name: Increment DNS serial
  command: >
    az network private-dns record-set soa update
    --resource-group "{{ my_rg }}"
    --zone-name "{{ my_domain }}"
    --serial-number "{{ new_serial }}"

This is accepted by Azure at least.

It does not update serial for me however. I can update other SOA paramters like refresh time or minimum TTL, but not the serial number; but this is different issue.

Dmytro
  • 216
  • 1
  • 4
  • 14