This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Traefik

Traefik

The administrator owns the proxy directory, configurations, TLS inputs, binary, and unit. The service account can write only its data and log directories; custom configuration and executable paths must have administrator-owned ancestors and stay outside those writable directories. Static configuration can contain credentials and is installed with mode 0640.

Both rendered configurations pass controller-side TOML/YAML syntax validation before installation. Startup inputs (static configuration, binary, trust CA, Basic Auth verifier, and unit) restart the service only when changed. Dynamic routing uses Traefik’s file watcher. Unchanged runs keep the process running; the unit has no SIGHUP reload action. Syntax validation does not prove route semantics or external issuer reachability.

Installation retains temporary backups. If staging or startup fails, available prior files are restored and a previously active service is restarted before the play reports failure. A first installation has no previous deployment to restore. Failed recovery preserves its backups; successful activation or recovery removes them. This covers startup rejection, not failures after a successful startup or invalid dynamic routing accepted by the process.

Local ACME enrollment is cached in administrator-only eab.json (mode 0600). The Vault request runs on the controller without privilege escalation; cache installation runs on the managed host with its declared administrator ownership. Unchanged deployments reuse it without issuing another Vault request. The first upgrade creates the cache once. Changing the issuer path or setting traefik_rotate_eab: true requests a new binding; reset the flag afterwards. If the ACME account state is lost, rotate its single-use enrollment binding before re-enrolling. Keep the cache and ACME account data private.

Set traefik_basic_auth_src to the controller-side verifier file and use traefik_basic_auth_path as usersFile in the dynamic configuration. The role installs the verifier with mode 0640 and restores it with the other startup inputs if activation fails.

Configure the Prometheus entry point in the deployment’s static Traefik configuration. Use the role’s default metrics port, 9100, and configure the host firewall to allow the collector.

1 - Defaults

Defaults for traefik
traefik_user: traefik
traefik_no_user: false
traefik_owner: root
traefik_user_uid: 3578
traefik_dir: "/opt/traefik"
traefik_log_dir: "{{ traefik_dir }}/logs"
traefik_data_dir: "{{ traefik_dir }}/data"
traefik_tls_dir: "{{ traefik_dir }}/tls"
traefik_basic_auth_src: null
traefik_basic_auth_path: "{{ traefik_tls_dir }}/basic-auth.htpasswd"
traefik_disk:
traefik_mtls_ca_local_path: "{{ role_path }}/files/traefik_mtls_ca.crt"
traefik_mtls_ca_path: "{{ traefik_tls_dir }}/mtls_ca.crt"
traefik_acme_path: "{{ undefined }}"
traefik_config_dir: "{{ traefik_dir }}/configs"
traefik_config_path: "{{ traefik_config_dir }}/traefik.toml"
traefik_disable_eab: false
traefik_config_local_path: "files/traefik.toml"
traefik_dynamic_config_path: "{{ traefik_config_dir }}/traefik_dynamic.toml"
traefik_dynamic_config_local_path: "files/traefik_dynamic.toml"
traefik_service_path: "/lib/systemd/system/traefik.service"
traefik_service_scope: system
traefik_bin_local_path: "{{ role_path }}/files/traefik"
traefik_bin_path: /usr/bin/traefik
traefik_vault_bin_local_path: "{{ role_path }}/files/vault"
traefik_eab_cache_path: "{{ traefik_config_dir }}/eab.json"
# Rotate explicitly after losing an ACME account or its enrollment state.
traefik_rotate_eab: false
traefik_metrics_port: 9100