feat(ddns): support Porkbun in the DDNS
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
62c7d2d4c0
commit
9c5a185588
7 changed files with 37 additions and 52 deletions
12
roles/ddns/defaults/main.yml
Normal file
12
roles/ddns/defaults/main.yml
Normal 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
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -1,34 +1,23 @@
|
||||||
---
|
---
|
||||||
- name: Install the config file
|
- name: Install the config file for DDNS
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: templates/inadyn.conf
|
src: templates/ddns.ini
|
||||||
dest: /etc/inadyn.conf
|
dest: /etc/ddns.conf
|
||||||
mode: 0600
|
mode: 0600
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
|
||||||
- name: Create the cache directory
|
- name: Install the DDNS quadlet
|
||||||
ansible.builtin.file:
|
ansible.builtin.template:
|
||||||
path: /var/cache/inadyn
|
src: templates/ddns.container
|
||||||
state: directory
|
dest: /etc/containers/systemd/ddns.container
|
||||||
mode: 0700
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: Install the unit files
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: files/{{ item }}
|
|
||||||
dest: /etc/systemd/system/{{ item }}
|
|
||||||
mode: 0644
|
mode: 0644
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
loop:
|
|
||||||
- ddns.service
|
|
||||||
- ddns.timer
|
|
||||||
|
|
||||||
- name: Enable the timer
|
- name: Enable the DDNS quadlet
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
enabled: true
|
enabled: true
|
||||||
name: ddns.timer
|
name: ddns.service
|
||||||
state: "started"
|
state: "started"
|
||||||
|
|
12
roles/ddns/templates/ddns.container
Normal file
12
roles/ddns/templates/ddns.container
Normal 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
|
4
roles/ddns/templates/ddns.ini
Normal file
4
roles/ddns/templates/ddns.ini
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
DOMAIN={{ ddns_domain }}
|
||||||
|
SUBDOMAINS={{ ','.join(ddns_subdomains) }}
|
||||||
|
APIKEY={{ ddns_porkbun_apikey }}
|
||||||
|
SECRETAPIKEY={{ ddns_porkbun_secretapikey }}
|
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in a new issue