Skip to content

Commit

Permalink
Add DDNS Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
davestephens committed Jul 20, 2023
1 parent 8b4755c commit f0965e6
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Cloudflare DDNS](https://hub.docker.com/r/joshuaavalon/cloudflare-ddns/) - automatically update Cloudflare with your IP address
* [CouchPotato](https://couchpota.to/) - for downloading and managing movies
* [Dashy](https://dashy.to/) - A self-hosted startpage for your server. Easy to use visual editor, status checking, widgets, themes and tons more!
* [DDNS Updater](https://github.com/qdm12/ddns-updater) - dynamic dns updater for serveral providers
* [Deluge](https://dev.deluge-torrent.org/) - A lightweight, Free Software, cross-platform BitTorrent client.
* [DokuWiki](https://www.dokuwiki.org/) - A simple to use and highly versatile Open Source wiki software that doesn't require a database.
* [Drone CI](https://drone.io) - A self-service Continuous Integration platform for busy development teams.
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
tags:
- dashy

- role: ddns_updater
tags:
- ddns_updater

- role: deluge
tags:
- deluge
Expand Down
40 changes: 40 additions & 0 deletions roles/ddns_updater/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
ddns_updater_enabled: false
ddns_updater_available_externally: "false"

# directories
ddns_updater_data_directory: "{{ docker_home }}/ddns_updater"

# network
ddns_updater_port: 8202
ddns_updater_hostname: "ddns-updater"

# docker
ddns_updater_container_name: ddns_updater

# specs
ddns_updater_memory: 1g

# gotify
# ddns_updater_gotify_token: "token"
# gotify_url: "https://gotify.{{ ansible_nas_domain }}"

# DDNS Updater Config
# Period of IP address check
ddns_updater_period: 5m

# Duration to cooldown between updates for each record. This is useful to avoid being rate limited or banned.
ddns_updater_cooldown_period: 5m

# Timeout for all HTTP requests
ddns_updater_http_timeout: 10s

# ddns_updater_config describes the content of the config.json used to configure the updater.
# see https://github.com/qdm12/ddns-updater#configuration for more info
#
# ddns_updater_config:
# settings:
# - provider: namecheap
# domain: example.com
# host: "@"
# password: e5322165c1d74692bfa6d807100c0310
54 changes: 54 additions & 0 deletions roles/ddns_updater/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
- name: Start DDNS Updater
block:
- name: Create DDNS Updater Directories
ansible.builtin.file:
path: "{{ ddns_updater_data_directory }}"
state: directory

- name: Check config is defined
ansible.builtin.fail:
msg: "Please configure DDNS Updater by setting ddns_updater_config in your inventory nas.yml."
when: ddns_updater_config is not defined

- name: Generate config.json
ansible.builtin.copy:
content: "{{ ddns_updater_config | to_nice_json }}"
dest: "{{ ddns_updater_data_directory }}/config.json"
register: ddns_updater_config

- name: DDNS Updater Container
community.docker.docker_container:
name: "{{ ddns_updater_container_name }}"
image: qmcgaw/ddns-updater:latest
pull: true
ports:
- "{{ ddns_updater_port }}:8000"
volumes:
- "{{ ddns_updater_data_directory }}:/updater/data:rw"
env:
TZ: "{{ ansible_nas_timezone }}"
GOTIFY_TOKEN: "{{ ddns_updater_gotify_token | default('') }}"
GOTIFY_URL: "{{ gotify_url | default('') }}"
PERIOD: "{{ ddns_updater_period }}"
UPDATE_COOLDOWN_PERIOD: "{{ ddns_updater_cooldown_period }}"
HTTP_TIMEOUT: "{{ ddns_updater_http_timeout }}"
restart_policy: unless-stopped
restart: "{{ ddns_updater_config is changed }}"
memory: "{{ ddns_updater_memory }}"
labels:
traefik.enable: "{{ ddns_updater_available_externally }}"
traefik.http.routers.airsonic.rule: "Host(`{{ ddns_updater_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.airsonic.tls.certresolver: "letsencrypt"
traefik.http.routers.airsonic.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.airsonic.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.airsonic.loadbalancer.server.port: "8000"
when: ddns_updater_enabled is true

- name: Stop DDNS Updater
block:
- name: Stop DDNS Updater
community.docker.docker_container:
name: "{{ ddns_updater_container_name }}"
state: absent
when: ddns_updater_enabled is false
44 changes: 44 additions & 0 deletions website/docs/applications/system-tools/ddns_updater.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "DDNS Updater"
---

Lightweight universal DDNS Updater with a web UI.

Homepage: [https://github.com/qdm12/ddns-updater](https://github.com/qdm12/ddns-updater)

Light container updating DNS A and/or AAAA records periodically for multiple DNS providers.

## Usage

Set `ddns_updater_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

## Specific Configuration

Ensure that the `ddns_updater_config` variable is set with your DDNS Updater configuration. The configuration is converted from YAML into JSON, required by the DDNS Updater application. Use [json2yaml](https://www.json2yaml.com/) to check your configuration format.


The following configuration:

```yaml
ddns_updater_config:
settings:
- provider: namecheap
domain: example.com
host: "@"
password: e5322165c1d74692bfa6d807100c0310
```
...will be serialised to:
```json
{
"settings": [
{
"provider": "namecheap",
"domain": "example.com",
"host": "@",
"password": "e5322165c1d74692bfa6d807100c0310"
}
]
}
```

0 comments on commit f0965e6

Please sign in to comment.