From ec961db180711a9a5c4be438616f1d51be3df014 Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sat, 8 May 2021 18:22:48 +0200 Subject: [PATCH] DDNS: Fix duplicated config variable --- README.md | 2 +- tasks/dyndns.yml | 4 ++-- templates/ddns-hosts.sh | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b00c26c..1f9303a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ This task and it's configuration files might be quite specific for the [davd/doc Mandatory variables: - `ddns_server_domain`: Domain name of the DynDNS server - `ddns_passphrase`: Passphrase for updating dynDNS entries -- `ddns_domain`: Domain where the host's entries are created as `$hostname.$ddns_domain` +- `ddns_zone`: Domain where the host's entries are created as `$hostname.$ddns_zone` Optional variable: - `ddns_silence`: Set to true to silence stderr too diff --git a/tasks/dyndns.yml b/tasks/dyndns.yml index b213e56..4836af7 100644 --- a/tasks/dyndns.yml +++ b/tasks/dyndns.yml @@ -15,10 +15,10 @@ owner: "{{ ansible_user_id }}" group: "{{ ansible_user_id }}" mode: 0775 -- name: "dyndns - Create cronjob for {{ ddns_domain }} dynDNS script" +- name: "dyndns - Create cronjob for {{ ddns_zone }} dynDNS script" become: yes cron: - name: "{{ ddns_domain }} dynDNS" + name: "{{ ddns_zone }} dynDNS" minute: "*/5" hour: "*" job: "/usr/local/bin/ddns-hosts.sh > /dev/null{% if ddns_silence is defined and ddns_silence is sameas true %} 2>&1{% endif %}" diff --git a/templates/ddns-hosts.sh b/templates/ddns-hosts.sh index 15418c0..1d53ab4 100644 --- a/templates/ddns-hosts.sh +++ b/templates/ddns-hosts.sh @@ -13,7 +13,8 @@ fi ip6addr='' ip4addr='' if [ $platform = 'linux' ]; then - ip6addr=$(ip -6 addr show scope global | grep inet6 | tail -1 | egrep -o '([0-9abcdef]{4}[0-9:abcdef]*)') + # only accept global IPv6 addresses (starting with 2 or 3) + ip6addr=$(ip -6 addr show scope global | grep inet6 | tail -1 | egrep -o '([0-9abcdef]{4}[0-9:abcdef]*)' | egrep '^[2,3]') # filter local IPv4 address ranges (172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16) ip4addr=$(ip -4 addr show scope global | grep inet | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | grep -Ev '172.(1[6-9]|2[0-9]|3[0-1])' | grep -Ev '10.' | grep -Ev '192.168.' | head -n 1) elif [ $platform = 'freebsd' ]; then