Nosmoht / ansible-module-powerdns

Ansible module to manage PowerDNS entries
Apache License 2.0
71 stars 51 forks source link

SRV records #18

Closed retr0h closed 4 years ago

retr0h commented 5 years ago

I'm trying to add SRV records with the module. However, it appears the module will only add one record total.

[jodewey:~/git/engx-ansible]   : DNACENGEX-2083-dns(+28/-28)+ ± dig _mysql._udp.dnac.xxx.com SRV

; <<>> DiG 9.10.6 <<>> _mysql._udp.dnac.xxx.com SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25306
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;_mysql._udp.dnac.xxx.com.        IN      SRV

;; ANSWER SECTION:
_mysql._udp.dnac.xxx.com. 300 IN  SRV     0 5 9104 dnac-dashboard-mysql-slave.dnac-dashboard-staging.svc.cluster.local.

;; AUTHORITY SECTION:
xxx

;; ADDITIONAL SECTION:
xxx

;; Query time: 48 msec
;; SERVER: 171.70.168.183#53(171.70.168.183)
;; WHEN: Wed Sep 18 18:17:06 PDT 2019
;; MSG SIZE  rcvd: 240
blake commented 5 years ago

@retr0h Can you share an example of the playbook & process you're using to create the SRV records? I'd like to clarify what the expected behavior is here.

Possibly related, I have a patch which enables powerdns_record to add multiple hostnames to a single MX record entry. Assuming the behavior I implemented there is what you're looking for, it shouldn't take much to get it working for SRV records as well.

retr0h commented 5 years ago

@blake

The inventory:

pdns_svr_create:
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql-slave.dnac-dashboard-production.svc.cluster.local.
    ttl: 300
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql-slave.dnac-dashboard-staging.svc.cluster.local.
    ttl: 300
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql-slave.dnac-dashboard-dev.svc.cluster.local.
    ttl: 300
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql.dnac-dashboard-production.svc.cluster.local.
    ttl: 300
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql.dnac-dashboard-staging.svc.cluster.local.
    ttl: 300
  - name: _mysql._udp.dnac.xxx.com.
    zone: _udp.dnac.xxx.com
    type: SRV
    content: 0 5 9104 dnac-dashboard-mysql.dnac-dashboard-dev.svc.cluster.local.
    ttl: 300

playbook

- hosts: dns-primary
  become: true
  tasks:
    - name: Create records
      powerdns_record:
        name: "{{ item.name }}"
        zone: "{{ item.zone }}"
        type: "{{ item.type }}"
        content: "{{ item.content }}"
        ttl: "{{ item.ttl }}"
        pdns_host: "{{ pdns_bind_address }}"
        pdns_port: "{{ pdns_api_port }}"
        pdns_api_key: "{{ pdns_api_password }}"
        state: "{{ item.state | default('present') }}"
      loop: "{{ pdns_hosts_create }}"

However, as reported in the original issue, only the last SRV record is ever added.

blake commented 5 years ago

@retr0h Just posted a PR which should resolve your issue. I tested these changes with the playbook you provided. The records are successfully created the after adding exclusive: no to the powerdns_record module parameters.

retr0h commented 4 years ago

I just tried this out, and oddly it doesn't appear to be working. I still only have one record (the last) even when passing exclusive: no

blake commented 4 years ago

Could you share which version of PowerDNS you’re using? Would you mind providing debugging output from the playbook run to assist with troubleshooting?