The sweep now fails the step when a timestamp cannot be parsed or a container it removes is still there, while tolerating one another run's sweep removed first. Its 30-minute bound and the job's timeout point at each other, since a shorter bound would remove a live run's containers. The concurrency comments of Lint and Build now say that runs on one ref queue rather than cancel, and the scenarios' comment names the run script as what removes their containers. The workflow test checks the label filters of the sweep and cleanup steps by name. Assisted-by: Claude Code:claude-opus-5-5
traefik
Installs the Traefik reverse proxy as a systemd-managed binary, renders its static and dynamic configuration with Cloudflare DNS-challenge certificates, opens its ports through the mortis.kamino.ufw role, and optionally updates or removes it (removal also deletes its ufw rules). Variables and their types are defined in meta/argument_specs.yml, which is the source of truth.
Supported platforms
Ubuntu 24.04 (noble), the image the molecule scenario runs on. The role uses ansible.builtin.apt, so Debian-family hosts only, and needs outbound access to github.com for the release archive and checksum file. Only traefik_install_type: binary exists.
Requirements and run order
- Use it by its fully qualified name,
mortis.kamino.traefik. - Run the
system_baselineandufwroles of this Collection first. The configure tasks passtraefik_ufw_service_rules(ports 80 and 443 by default) to theservice_rulesentry point ofmortis.kamino.ufw, ownertraefik, which needs ufw installed and active and the SSH rule in place. See the README ofmortis.kamino.ufw. - Secrets:
traefik_cloudflare_emailandtraefik_cloudflare_api_tokenhave no role default and are required. Map them from vaulted variables in inventory; the role never holds the values itself. traefik_domainhas no role default and must be set in inventory.- Updates: the update path stages the verified binary and hands the swap to
mortis.kamino._binary_update, an internal role of this Collection. - Pin
traefik_versionin inventory to move Traefik independently of Collection releases; the role default changes only with a release.
Role variables
| Variable | Default | Required | Description |
|---|---|---|---|
traefik_domain |
none | yes | Zone appended to the dashboard and app subdomains. |
traefik_update |
false |
no | Run the update tasks when the installed version differs from traefik_version: download and verify into a staging directory before anything is stopped, then mortis.kamino._binary_update stops, backs up, swaps, restarts and checks the version, and rolls back on failure. |
traefik_remove |
false |
no | Stop and disable the service, remove unit and binary, then delete the role's ufw rules (owner traefik, ufw_service_state: absent). The last remove task deletes the role's ufw rules, so ufw must be active on the host or that task fails. Prerequisites, install, configure and update are skipped. |
traefik_remove_data |
false |
no | With traefik_remove, also delete traefik_config_dir. |
traefik_install_type |
binary |
no | Task directory selector; only binary exists. |
traefik_version |
pinned in defaults/main.yml |
no | Release tag to install. |
traefik_arch |
amd64 |
no | Archive architecture. |
traefik_os |
linux |
no | Archive OS. |
traefik_archive_name |
traefik_<version>_<os>_<arch>.tar.gz |
no | Archive file name (templated). |
traefik_local_archive |
/tmp/traefik.tar.gz |
no | Download destination, removed after extraction. |
traefik_bin_path |
/usr/local/bin/traefik |
no | Binary path used by the unit and version checks; only the traefik file of the archive is extracted into its directory, so the file name must stay traefik. Only the traefik file is extracted, so the archive's CHANGELOG.md and LICENSE.md never land there. |
traefik_config_dir |
/etc/traefik |
no | Static config, traefik.env and logs directory. |
traefik_dynamic_dir |
<traefik_config_dir>/dynamic |
no | File-provider directory. |
traefik_acme_file |
<traefik_config_dir>/acme.json |
no | ACME storage, mode 0600. |
traefik_service_unit |
/etc/systemd/system/traefik.service |
no | Systemd unit file path written (and removed on traefik_remove). |
traefik_dns_challenge_resolvers |
[] |
no | host:port or [ipv6]:port resolvers for the ACME DNS-01 propagation check; empty omits the resolvers block. Set per environment. |
traefik_user |
traefik |
no | System user and group running the service. |
traefik_log_rotate_frequency |
daily |
no | How often logrotate rotates <traefik_config_dir>/logs/*.log (/etc/logrotate.d/traefik, copytruncate). |
traefik_log_rotate_count |
14 |
no | Rotated log files to keep. |
traefik_log_rotate_max_size |
500M |
no | Size that rotates a log early when logrotate runs. |
traefik_dynamic_apps |
[] |
no | Extra apps: service_name, subdomain (trailing dot), server_url, optional pass_host_header. |
traefik_dashboard_enabled |
false |
no | Serve the dashboard. When true, traefik_dashboard_basicauth_users must be non-empty or the role fails. |
traefik_dashboard_subdomain |
traefik. |
no | Dashboard host prefix. |
traefik_dashboard_basicauth_users |
[] |
no | htpasswd lines for dashboard basicAuth (credentials, no_log); required when the dashboard is enabled, ignored otherwise. |
traefik_dynamic_middlewares |
{} |
no | Extra middlewares; dashboard-auth is reserved. |
traefik_trusted_proxy_ips |
127.0.0.1/32, ::1/128 |
no | CIDRs trusted for forwarded headers. |
traefik_cloudflare_email |
none | yes | Cloudflare e-mail (no_log, vaulted source). |
traefik_cloudflare_api_token |
none | yes | Cloudflare API key (no_log, vaulted source). |
traefik_headers |
HSTS and security headers, see defaults | no | default-headers middleware; overriding replaces the whole mapping. |
traefik_ufw_service_rules |
allow 80 and 443 | no | Rules passed to ufw service_rules (owner traefik). |
Tags
traefik, remove, install, configure and update select their task files. prereqs tasks are also tagged always, so they run under any tag. The required-input assert (traefik_domain and the Cloudflare inputs) is tagged always and runs before the remove path, so traefik_remove=true also needs them defined.
ufwandbinaryselect nothing on their own: they sit only on tasks inside included files (configure.yml,install.yml) whose includes inmain.ymldo not carry them. Theufwinclude setsapply: tags, so theservice_rulestasks also run under--tags traefikor--tags configure. The rule removal intasks/binary/remove.ymlalso carriesufwandremove, butmain.ymlincludes the remove path only undertraefikandremove.healthis not read-only: it re-rendersdynamic.yml(which can notifyRestart Traefik) and checks that the service isactive.
Example play
- name: Install Traefik
hosts: proxy
roles:
- role: mortis.kamino.traefik
vars:
traefik_domain: example.com
traefik_cloudflare_email: [email protected]
traefik_cloudflare_api_token: "{{ vault_cloudflare_token }}"
traefik_dynamic_apps:
- {service_name: whoami, subdomain: "whoami.", server_url: "http://127.0.0.1:8081"}
Update or remove: pass -e traefik_update=true, or -e "traefik_remove=true traefik_remove_data=true" --tags remove.
Notes
- The role is not a state selector.
main.ymlruns prerequisites and configure unlesstraefik_removeis true; install runs only when the binary is absent; update only whentraefik_updateis true; remove only whentraefik_removeis true, and then every other task inmain.ymlis skipped. - Download integrity: the archive SHA-256 must appear in the release's checksum file or the play fails.
- Secrets:
traefik.env(mode 0600, root) anddynamic.ymlare rendered withno_log: true, and no backups are kept, so--diffnever shows them.dynamic.ymlmay hold dashboard htpasswd hashes. - The unit sets
NoNewPrivileges,ProtectSystem=full,ProtectHome,PrivateTmp,PrivateDevices,ProtectKernelModules,ProtectKernelTunables,MemoryDenyWriteExecuteandCAP_NET_BIND_SERVICE. The molecule scenario disables the namespace-based sandboxing and theUser=switch with a drop-in because its container is unprivileged, so that sandboxing is not covered by CI. - The role fails early (assert at the top of
tasks/main.yml, runs under any tag and before theremoveinclude) whentraefik_dns_challenge_resolversis not a list ofhost:port(or[ipv6]:port) strings, whentraefik_bin_pathis not an absolute path ending intraefik, or whentraefik_config_dirortraefik_service_unitis not absolute. - The DNS-challenge resolvers are environment-specific, so the role default is empty, which omits the
resolversblock. - The play fails when the service is not
activeafter start. - Molecule's verify also updates to another release and back with
traefik_update(a real download, checksum check and swap) and asserts the version, an active unit and no leftovers. - Molecule's second play expects the failure message containing
unauthenticated Traefik dashboard(the dashboard guard: enabled without validuser:hashusers); its third play expectscollides with the middleware, raised by the dashboard-auth collision assert, which runs whenever users are set, also with the dashboard off.