Dyndns Ansible Role
This repository has been archived on 2026-10-12. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-27 16:47:45 +00:00
.gitea/workflows feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
defaults feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
meta feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
tasks feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
templates feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
.gitignore feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
CHANGELOG.md Prettified Code! 2026-04-27 16:47:45 +00:00
LICENSE feat: added basic dyndns setup 2026-04-27 18:46:41 +02:00
README.md Prettified Code! 2026-04-27 16:47:45 +00:00

dyndns

Installs a shell script and cron job that tracks the host's public IP and updates Hetzner DNS A records whenever it changes.

Requirements

  • cron and curl (installed automatically)
  • Hetzner DNS API token(s)

Variables

Variable Default Description
dyndns_path /dyndns Base directory for per-zone configuration. See Usage for the expected layout.
dyndns_interval */5 Cron minute expression controlling how often the IP check runs.
dyndns_uninstall false Removes the cron job and the dyndns script.
dyndns_purge false Also removes dyndns_path. Requires dyndns_uninstall: true. Irreversible.

Usage

Directory layout

The script reads zone configuration from subdirectories of dyndns_path. Each subdirectory name is a DNS zone ID, and must contain:

  • .token — Hetzner DNS API token for that zone
  • One file per record name to update (filename = record name, content ignored)
/dyndns/
└── <zone-id>/
    ├── .token
    ├── home          # updates home.<zone>
    └── vpn           # updates vpn.<zone>

Populate these files before or after running the role. The script skips any zone directory that is missing a .token file.

Custom interval

dyndns_interval: "*/10" # check every 10 minutes

Custom base path

dyndns_path: /etc/dyndns

Managing individual records

Use tasks/record.yml as a standalone include to add or remove a single record without re-running the full role:

- ansible.builtin.include_role:
    name: dyndns
    tasks_from: record
  vars:
    dyndns_zone: "<zone-id>"
    dyndns_record: "home"
    dyndns_record_state: present # or absent

The task requires the zone directory to already exist (i.e. the role has been run for that zone). dyndns_record_state defaults to present if omitted.

Uninstall

To remove the cron job and the script:

dyndns_uninstall: true

To also remove the configuration directory (irreversible):

dyndns_uninstall: true
dyndns_purge: true

Notes

  • The script installs to /usr/local/bin/dyndns and runs as root.
  • Public IP is resolved via ipinfo.io, ipecho.net, and checkip.amazonaws.com in order; the first successful response wins.
  • Updates are skipped when the IP has not changed since the last run (tracked in dyndns_path/.last_ip).
  • All output is appended to /var/log/dyndns.log.