From 20942f8f4b1ad9e068e3db77ef5d80be3257023f Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 3 Aug 2022 20:19:09 +0200 Subject: [PATCH 1/3] Add role dd24-dyndns-cron Setup cron job to call curl for DynDNS update --- roles/dd24-dyndns-cron/defaults/main.yml | 5 +++++ roles/dd24-dyndns-cron/handlers/main.yml | 10 ++++++++++ roles/dd24-dyndns-cron/tasks/main.yml | 18 ++++++++++++++++++ .../templates/dd24-dyndns.cron.j2 | 6 ++++++ 4 files changed, 39 insertions(+) create mode 100644 roles/dd24-dyndns-cron/defaults/main.yml create mode 100644 roles/dd24-dyndns-cron/handlers/main.yml create mode 100644 roles/dd24-dyndns-cron/tasks/main.yml create mode 100644 roles/dd24-dyndns-cron/templates/dd24-dyndns.cron.j2 diff --git a/roles/dd24-dyndns-cron/defaults/main.yml b/roles/dd24-dyndns-cron/defaults/main.yml new file mode 100644 index 0000000..0f9336d --- /dev/null +++ b/roles/dd24-dyndns-cron/defaults/main.yml @@ -0,0 +1,5 @@ +# DD24 Cron configuration +--- +dyndns_domain: www.example.com +dyndns_password: yourpassword +dyndns_ip: auto diff --git a/roles/dd24-dyndns-cron/handlers/main.yml b/roles/dd24-dyndns-cron/handlers/main.yml new file mode 100644 index 0000000..49c802c --- /dev/null +++ b/roles/dd24-dyndns-cron/handlers/main.yml @@ -0,0 +1,10 @@ +# handlers file for cron-dd24-dyndns +--- +- name: reload cron + ansible.builtin.shell: + cmd: service cron reload + warn: no +# Use the shell call because the task sometimes has problems finding the service state +# service: +# name: cron +# state: restarted diff --git a/roles/dd24-dyndns-cron/tasks/main.yml b/roles/dd24-dyndns-cron/tasks/main.yml new file mode 100644 index 0000000..5060260 --- /dev/null +++ b/roles/dd24-dyndns-cron/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Make sure cron and curl are installed + apt: + name: + - cron + - curl + state: present + +- name: Setup cron file for DD24 updates + ansible.builtin.template: + src: "templates/dd24-dyndns.cron.j2" + dest: "/etc/cron.d/dd24-dyndns" + owner: root + group: root + mode: "0644" + notify: reload cron + # There is ansible.builtin.cron, but this makes configuration much + # more complicated, so we stick to the template. diff --git a/roles/dd24-dyndns-cron/templates/dd24-dyndns.cron.j2 b/roles/dd24-dyndns-cron/templates/dd24-dyndns.cron.j2 new file mode 100644 index 0000000..e3119ab --- /dev/null +++ b/roles/dd24-dyndns-cron/templates/dd24-dyndns.cron.j2 @@ -0,0 +1,6 @@ +# /etc/cron.d/dd24-dyndns: Cron call to renew DynDNS entry + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +*/5 * * * * root curl "https://dynamicdns.key-systems.net/update.php?hostname={{dyndns_domain}}&password={{dyndns_password}}&ip={{dyndns_ip}}" > /dev/null From 8375a835f49114a0ed4c85aa5b17cb2d5a36bf6d Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 3 Aug 2022 20:19:38 +0200 Subject: [PATCH 2/3] Add configuration for DD24 dyndns role --- inventory.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/inventory.yml b/inventory.yml index beed07b..d9459f3 100644 --- a/inventory.yml +++ b/inventory.yml @@ -46,6 +46,16 @@ all: sudo: yes docker: yes + # Data for DD24 dyndns updates + dyndns_domain: "dyndns.n39.eu" + dyndns_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 65653833376630636530373933326362316164353965643732323634393934383764376563613063 + 6632333438636434376666666132313139393363366665380a353737326231613862333866323031 + 30353966366436613433363937643463613332643133643637643232633238373638303063646635 + 3132306530356431630a333538616466643933643230383165646362643738616237383937666332 + 3164 + hosts: tau.netz39.de: server_admin: "admin+tau@netz39.de" From 2c9870cd28539d61474571228063cbf48e120a85 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 3 Aug 2022 20:19:48 +0200 Subject: [PATCH 3/3] Call DD24 dyndns role on pottwal --- pottwal.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pottwal.yml b/pottwal.yml index 035052a..a4df212 100644 --- a/pottwal.yml +++ b/pottwal.yml @@ -28,6 +28,8 @@ vars: docker_data_root: "/srv/docker" - role: apache + - role: dd24-dyndns-cron + # variables are set in the inventory tasks: