feat(ddns): support Porkbun in the DDNS

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-11-11 17:30:02 +01:00
parent 62c7d2d4c0
commit b75822372a
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8
7 changed files with 37 additions and 52 deletions

View file

@ -0,0 +1,12 @@
---
# Domain for which the DDNS manages DDNS entries
ddns_domain: None
# List of all subdomains on the said domain for which the IP should be set
ddns_subdomains: []
# apikey provided by Porkbun
ddns_porkbun_apikey: None
# secretapikey provided by Porkbun
ddns_porkbun_secretapikey: None

View file

@ -1,7 +0,0 @@
[Unit]
Description=Run inadyn in a container to update DNS
After=network.target
[Service]
Type=oneshot
ExecStart=podman run --rm -v "/etc/inadyn.conf:/etc/inadyn.conf" -v "/var/cache/inadyn:/var/cache/inadyn" docker.io/troglobit/inadyn:latest -1 --cache-dir=/var/cache/inadyn

View file

@ -1,10 +0,0 @@
[Unit]
Description=Run inadyn every 15 minutes
[Timer]
OnCalendar=*:00,15,30,45:00
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target

View file

@ -1,34 +1,23 @@
---
- name: Install the config file
- name: Install the config file for DDNS
ansible.builtin.template:
src: templates/inadyn.conf
dest: /etc/inadyn.conf
src: templates/ddns.ini
dest: /etc/ddns.ini
mode: 0600
owner: root
group: root
- name: Create the cache directory
ansible.builtin.file:
path: /var/cache/inadyn
state: directory
mode: 0700
owner: root
group: root
- name: Install the unit files
ansible.builtin.copy:
src: files/{{ item }}
dest: /etc/systemd/system/{{ item }}
- name: Install the DDNS quadlet
ansible.builtin.template:
src: templates/ddns.container
dest: /etc/containers/systemd/ddns.container
mode: 0644
owner: root
group: root
loop:
- ddns.service
- ddns.timer
- name: Enable the timer
- name: Enable the DDNS quadlet
ansible.builtin.systemd_service:
daemon_reload: true
enabled: true
name: ddns.timer
name: ddns.service
state: "started"

View file

@ -0,0 +1,12 @@
[Unit]
Description=DDNS Update
[Container]
Image=docker.io/mietzen/porkbun-ddns:latest
EnvironmentFile=/etc/ddns.ini
[Service]
Restart=always
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,4 @@
DOMAIN={{ ddns_domain }}
SUBDOMAINS={{ ','.join(ddns_subdomains) }}
APIKEY={{ ddns_porkbun_apikey }}
SECRETAPIKEY={{ ddns_porkbun_secretapikey }}

View file

@ -1,15 +0,0 @@
period = 300
allow-ipv6 = true
provider cloudflare.com:1 {
username = {{ cloudflare_zone }}
password = {{ cloudflare_token }}
hostname = {{ host_fqdn }}
}
provider cloudflare.com:2 {
username = {{ cloudflare_zone }}
password = {{ cloudflare_token }}
hostname = {{ host_fqdn }}
wildcard = true
}