Skip to content

Commit

Permalink
Update ddns.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
agonzalezrh authored Dec 3, 2024
1 parent 61067b8 commit 62ded8d
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions playbooks/roles/infra-aws-sandbox/tasks/ddns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
set -o pipefail;
host -t ns -W 60 -R 10 {{ account_name }}.{{ ddns_domain }}
| awk '{ print $4 }'
| perl -pe 's/\.$//'
register: _recordfind
ignore_errors: true

Expand All @@ -21,39 +20,15 @@
set_fact:
ddns_ns_records: ""

- name: Delete all NS records that are not needed anymore
- name: Override NS records to DDNS
community.general.nsupdate:
server: "{{ ddns_server }}"
zone: "{{ ddns_domain }}"
record: "{{ account_name }}"
value: "{{ _z }}."
type: NS
port: "{{ ddns_port | d('53') }}"
key_name: "{{ ddns_key_name }}"
key_algorithm: "{{ ddns_key_algorithm | d('hmac-sha512') }}"
key_secret: "{{ ddns_key_secret }}"
state: absent
loop_control:
loop_var: _z
loop: "{{ ddns_ns_records | difference(ns_records) }}"
when: _z != ''

- name: Add NS records to DDNS
when: >-
ddns_ns_records | length == 0
or ddns_ns_records | difference(ns_records) | length != 0
or ns_records | difference(ddns_ns_records) | length != 0
community.general.nsupdate:
server: "{{ ddns_server }}"
zone: "{{ ddns_domain }}"
record: "{{ account_name }}"
value: "{{ _z }}."
server: "{{ lookup('dig', ddns_server) }}"
zone: "{{ ddns_domain }}."
record: "{{ account_name }}.{{ ddns_domain }}."
value: "{{ ns_records }}"
type: NS
port: "{{ ddns_port | d('53') }}"
key_name: "{{ ddns_key_name }}"
key_algorithm: "{{ ddns_key_algorithm | d('hmac-sha512') }}"
key_secret: "{{ ddns_key_secret }}"
state: present
loop: "{{ ns_records }}"
loop_control:
loop_var: _z

0 comments on commit 62ded8d

Please sign in to comment.