Traefik Ansible role https://doc.traefik.io/traefik/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-23 22:12:48 +00:00
.forgejo/workflows fix: fixed pipeline 2026-10-12 16:52:22 +07:00
defaults feat: adjusted dns settings 2026-11-23 23:12:38 +01:00
meta fix: fixed issue with role install 2026-08-19 22:59:40 +02:00
tasks feat: adjusted dns settings 2026-11-23 23:12:38 +01:00
templates feat: adjusted dns settings 2026-11-23 23:12:38 +01:00
CHANGELOG.md feat: adjusted dns settings 2026-11-23 23:12:38 +01:00
LICENSE feat: added initial version 2026-04-24 09:34:45 +02:00
README.md Prettified Code! 2026-11-23 22:12:48 +00:00

Traefik

Deploys a Traefik reverse proxy via Docker Compose with automatic TLS via Let's Encrypt and an optional admin dashboard.

Requirements

  • Docker
  • community.docker Ansible collection (>=5.2.0)

Variables

Variable Default Description
traefik_instance traefik Unique instance name. Used as Compose project name and container name.
traefik_version v3.7.19 Traefik image tag.
traefik_docker_path /docker/traefik Host path for Compose file, config, certs, and dynamic config.
traefik_ports ["80:80", "443:443"] List of host port mappings to expose.
traefik_acme_email ~ Required. Email address for Let's Encrypt certificate registration.
traefik_domain ~ Domain for the Traefik dashboard. When set, enables the dashboard with basic auth.
traefik_user admin Dashboard basic-auth username. Used when traefik_domain is set.
traefik_password ~ Dashboard basic-auth password (or traefik_password_hash) when traefik_domain is set. New salt each run, so the container is recreated every time.
traefik_password_hash ~ Precomputed bcrypt hash (htpasswd -nbB), used instead of traefik_password.
traefik_hetzner_token ~ Hetzner API token. When set, switches ACME from HTTP challenge to Hetzner DNS challenge.
traefik_dns_delay 30 Seconds before the DNS-01 record is checked.
traefik_dns_resolvers ["1.1.1.1:53", "1.0.0.1:53"] DNS servers the DNS-01 check uses. Empty list = the container's resolver.
traefik_container_dns [] dns: servers of the Traefik container.
traefik_loglevel ERROR Log level. One of: DEBUG, INFO, WARN, ERROR, FATAL, PANIC.
traefik_entrypoints HTTP→HTTPS redirect Raw TOML block injected into [entryPoints]. Override to customize entry points.
traefik_custom_config ~ Raw TOML appended verbatim to the end of traefik.toml.
traefik_uninstall false Stops and removes containers and the compose directory.

Usage

Minimal setup:

traefik_acme_email: "admin@example.com"

With dashboard:

traefik_acme_email: "admin@example.com"
traefik_domain: "traefik.example.com"
traefik_password: "supersecret"

With Hetzner DNS challenge (required for wildcard certs or servers not reachable on port 80):

traefik_acme_email: "admin@example.com"
traefik_hetzner_token: "your-hetzner-api-token"

Uninstall

To stop and remove all containers and the compose directory:

traefik_uninstall: true

Notes

  • Traefik creates a Docker bridge network named traefik_web. Other containers that should be proxied must join this network and set the traefik.enable=true label.
  • Dynamic configuration files placed in {{ traefik_docker_path }}/dynamic are watched and applied without restart.
  • TLS is hardened to 1.2+ with a restricted cipher suite applied globally.
  • Containers are not proxied by default — each must opt in with traefik.enable=true.