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