Files
Defame1297andClaude Opus 5.5 589b71a312
Build / build (pull_request) Successful in 15s
Lint / lint (pull_request) Successful in 1m32s
Molecule / molecule (pull_request) Successful in 3m38s
feat(traefik): add the traefik role
Moves the traefik role from the environment repository, the first wave 2 role and the
first caller of the internal _binary_update role.

Against the source:
- The update path stages the downloaded, checksum-verified binary in a directory next to
  the live one and hands the stop, backup, swap, restart, version check and rollback to
  mortis.kamino._binary_update (include_role with apply tags, so --tags update reaches
  it). A download or checksum failure still leaves the running service untouched and
  says so; a failure in the swap keeps the rollback message of _binary_update.
- Two small behaviour changes come with _binary_update: the backup is taken whenever a
  live binary exists (the source skipped it when the binary reported no version), and a
  failure before the stop no longer restarts the running service.
- The legacy name guards (pre-rename variables of the environment) are dropped, as in
  the wave 1 roles, and the argument_specs and README no longer mention them.
- Environment references are gone from comments, the README and the argument_specs:
  issue numbers, host names, inventory paths, playbooks and the role's own history. The
  Renovate comment on traefik_version is dropped, since this repository has no manager
  for it; the README and argument_specs recommend pinning the version in inventory.
- meta namespace mortis; the scenario follows the Kamino conventions (header,
  test_sequence, no provisioner env) and calls the role by FQCN.
- The scenario's verify gains a real version bump: down to another release (v3.7.18)
  and back to the role default with traefik_update, asserting the version, an active
  unit and no staging directory, backup or download left behind.

Changelog fragment, README Roadmap and the CLAUDE.md role list updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-20 19:20:37 +00:00

205 lines
9.5 KiB
YAML

---
argument_specs:
main:
short_description: Install, configure, update or remove Traefik as a systemd binary
description:
- >-
Optionally removes Traefik (C(traefik_remove)), installs required packages, the C(traefik) system user and
group, downloads and checksum-verifies the pinned release on first install, renders the static and dynamic
configuration, the secret environment file and the systemd unit, re-runs the C(mortis.kamino.ufw) role, and starts the
service. Optionally updates the binary in place (C(traefik_update)) with rollback.
- >-
C(traefik_domain), C(traefik_cloudflare_email) and C(traefik_cloudflare_api_token) have no role default and
are required. The environment supplies them, typically mapped from its own variables in group_vars.
options:
traefik_domain:
type: str
description:
- >-
DNS zone appended to C(traefik_dashboard_subdomain) and to each C(subdomain) of C(traefik_dynamic_apps) to
form the Host rule. No role default exists. Supplied by inventory.
- Required and asserted non-empty at role start by the tasks (not by this spec).
traefik_update:
type: bool
default: false
description:
- >-
When true the update tasks run after configuration. The installed version is compared with
C(traefik_version) and only a difference triggers a verified download into a staging directory, before
the service is stopped. The internal C(mortis.kamino._binary_update) role then stops, backs up, swaps,
restarts and checks the version, with rollback to the backup on failure.
traefik_remove:
type: bool
default: false
description:
- >-
When true the service is stopped and disabled, the unit file and the binary are removed, and the
C(ansible-ufw[traefik:...]) firewall rules are deleted (ufw must be active on the host, or that last task
fails). Prerequisites, install, configure and update are skipped for this run.
traefik_remove_data:
type: bool
default: false
description:
- Only read while C(traefik_remove) is true. When true C(traefik_config_dir) is deleted recursively, including the ACME store.
traefik_install_type:
type: str
default: binary
choices: [binary]
description:
- Selects the task directory that is included. Only C(binary) exists.
traefik_version:
type: str
description:
- >-
Traefik release tag to install, for example C(v3.7.14). The role default is a pinned tag, see
C(defaults/main.yml); pin it in inventory to move it independently of Collection releases.
traefik_arch:
type: str
default: amd64
description:
- Architecture part of the release archive name.
traefik_os:
type: str
default: linux
description:
- Operating system part of the release archive name.
traefik_archive_name:
type: raw
description:
- >-
Release archive file name. The role default is the Jinja expression
C(traefik_<traefik_version>_<traefik_os>_<traefik_arch>.tar.gz).
traefik_local_archive:
type: str
default: /tmp/traefik.tar.gz
description:
- Download destination of the release archive on the target. Removed after extraction.
traefik_bin_path:
type: str
default: /usr/local/bin/traefik
description:
- >-
Path of the Traefik binary. Used by the service unit, the version checks and removal. Only the
C(traefik) file of the archive is extracted into its directory, so the file name must stay C(traefik).
traefik_config_dir:
type: str
default: /etc/traefik
description:
- >-
Directory for C(traefik.yml) and the C(logs) directory. The secret file C(traefik.env) is written here
too. The role defaults of C(traefik_dynamic_dir) and C(traefik_acme_file) are derived from it.
traefik_dynamic_dir:
type: str
default: /etc/traefik/dynamic
description:
- Directory watched by the file provider. Holds C(dynamic.yml). The role default is the C(dynamic) subdirectory of C(traefik_config_dir).
traefik_acme_file:
type: str
default: /etc/traefik/acme.json
description:
- ACME certificate storage. Created empty when missing and kept mode 0600. The role default is C(acme.json) inside C(traefik_config_dir).
traefik_service_unit:
type: str
default: /etc/systemd/system/traefik.service
description:
- Path of the systemd unit file the role writes and, on removal, deletes. The service name stays C(traefik).
traefik_dns_challenge_resolvers:
type: list
elements: str
default: []
description:
- >-
Resolvers, as C(host:port) or C([ipv6]:port) strings, that the ACME DNS-01 challenge uses to check propagation. Empty omits
the C(resolvers) block, so Traefik uses the system resolver. Environment-specific, supplied by inventory.
traefik_user:
type: str
default: traefik
description:
- System user and group that own the configuration and run the service.
traefik_log_rotate_frequency:
type: str
default: daily
choices: [hourly, daily, weekly, monthly]
description:
- How often logrotate rotates the Traefik logs (C(/etc/logrotate.d/traefik)).
traefik_log_rotate_count:
type: int
default: 14
description:
- Number of rotated Traefik log files to keep.
traefik_log_rotate_max_size:
type: str
default: 500M
description:
- Size at which a log is rotated even before the interval is due (logrotate C(maxsize), for example C(500M)).
traefik_dynamic_apps:
type: raw
description:
- >-
List of extra routed applications, supplied by inventory. The role default is an empty list. Each item is a
mapping with C(service_name), C(subdomain) (including the trailing dot), C(server_url) and optionally
C(pass_host_header) (default true).
traefik_dashboard_enabled:
type: bool
default: false
description:
- >-
Serve the Traefik dashboard (C(api@internal)) on C(traefik_dashboard_subdomain). Off by default. The play
fails when it is true and C(traefik_dashboard_basicauth_users) is empty, so the dashboard is never
deployed without authentication.
traefik_dashboard_subdomain:
type: str
default: "traefik."
description:
- Prefix, including the trailing dot, placed before C(traefik_domain) for the dashboard Host rule.
traefik_dashboard_basicauth_users:
type: raw
no_log: true
description:
- >-
List of htpasswd lines C(user:hash) for basicAuth on the dashboard router. Required (non-empty) when
C(traefik_dashboard_enabled) is true and ignored otherwise. The role default is an empty list. These are
credentials, set them only from a vaulted variable file.
- The play fails when this is non-empty and C(traefik_dynamic_middlewares) also defines C(dashboard-auth).
traefik_dynamic_middlewares:
type: raw
description:
- >-
Mapping of extra middleware name to its Traefik configuration, rendered next to C(default-headers). The
role default is an empty mapping. The key C(dashboard-auth) is reserved.
traefik_trusted_proxy_ips:
type: raw
description:
- >-
List of CIDRs trusted for X-Forwarded-* headers on the websecure entrypoint. The role default is
C(127.0.0.1/32) and C(::1/128), for a tunnel client (such as cloudflared) that connects over loopback.
traefik_cloudflare_email:
type: raw
no_log: true
description:
- >-
Cloudflare account e-mail for the DNS challenge. Written to C(traefik.env) as C(CF_API_EMAIL) and to the
ACME resolver. No role default exists. Map it from a vaulted inventory variable.
- Required and asserted non-empty at role start by the tasks (not by this spec).
traefik_cloudflare_api_token:
type: raw
no_log: true
description:
- >-
Cloudflare API key for the DNS challenge. Written to C(traefik.env) as C(CF_API_KEY). No role default
exists. Map it from a vaulted inventory variable.
- Required and asserted non-empty at role start by the tasks (not by this spec).
traefik_headers:
type: dict
description:
- >-
Mapping rendered as the C(default-headers) middleware, applied to the websecure entrypoint. The role
default enables frame deny, XSS filter, nosniff, forced STS with subdomains and preload (15552000
seconds), SAMEORIGIN frame option and C(X-Forwarded-Proto) https. Overriding replaces the whole mapping.
traefik_ufw_service_rules:
type: raw
description:
- >-
Rules the role passes to the C(mortis.kamino.ufw) role as C(ufw_service_rules), owner C(traefik) (entry point
C(service_rules)). The role default allows ports 80 and 443. Same item schema as C(ufw_service_rules).