Adds cloudflared, a Cloudflare Tunnel daemon role with a mint entry point. It is the fourth role to call _binary_update, after gitea, gitea_runner and traefik. The role is ported from the maintainer's local role, with the changes listed below. It is the wave 2 extraction, so it is removed from the README Roadmap.
What changed compared with the source role
Updates. The role still stages the download and checks its sha256. Stop, backup, swap, restart, version check and rollback now run in mortis.kamino._binary_update, included with apply tags, so --tags update reaches the download. The cloudflared-specific stale-sha guard and the 0.0.0 handling stay in the role.
tasks/validate.yml (tag always). It checks the version and sha format. Ingress hostnames must be lowercase, may start with *., and must not contain whitespace or a newline. The user, group and directories must not contain a newline or %, and the directories must be absolute paths. The tunnel id must be a UUID. The secrets and, when DNS is managed, the zone are checked before any change.
Exception to "a secret is a required input." The tunnel id, credentials, account id and API token are not required: true. When one is missing, the role's own assert tells the operator to run the mint entry point, and that is the only way the first run on a new host can work. The reason is written in both argument_specs and the README. mint keeps the generated secret in no_log facts only. Persisting it is the consumer's job, as in gitea's mint.
New input cloudflared_manage_dns (default true). With false, every DNS call is skipped.
DNS handling:
the overwrite guard queries one hostname at a time with the name urlencoded;
hostnames compare case-insensitively;
the prune pages through result_info.total_pages;
config.yml is checked with ingress validate before it is written.
Fixes to behaviour carried over from the source role:
A 404 or a deleted tunnel now reaches the re-mint message. Before, it failed inside a hidden no_log task. Any other status fails with its HTTP code.
A removal now ends the role, as in gitea_runner; before, the same run reinstalled the daemon.
The mint block runs with become: false and checks the account id, token and tunnel name before it creates anything.
Dropped: the legacy-name guards.
Renamed: internal names now use __cloudflared_*, and the handler is now Restart cloudflared.
Moved: the meta namespace is now mortis.
Docs: changelog fragment changelogs/fragments/cloudflared-role.yml (minor_changes), the README status line, the list of _binary_update callers, and the Roadmap.
galaxy.yml is not bumped. The release is a separate PR.
Molecule (molecule/default)
A file:// download and a local Cloudflare API stub (files/cloudflare_api_stub.py, bound to 127.0.0.1 on a random port, exits after 1500 s).
Covers install, configure, the update through _binary_update, the lookup failures (404, deleted, other status), the input refusals, and mint (confirm guard, CI refusal, generation in memory).
The cleanup stops the stub only if the pid still belongs to the stub.
I grepped the diff and the commit messages for the #293 terms: domain, hosts and groups, private IPs, issue references to the other repo, its paths, and tunnel words. The remaining hits are intentional: mortis.kamino.* names, namespace/author in meta, the scenario's group_vars key and its own mint.yml. Test data uses only example.test/example.com, 192.0.2.10 and dummy UUIDs.
Verified (locally)
All commit and pre-push hooks pass, including ansible-lint (production profile), yamllint, ruff, REUSE, the changelog lint and gitleaks.
ansible-test sanity: 0 errors, pylint and pep8 included on the stub.
tests/scripts: 243 tests pass.
--syntax-check passes on the 5 scenario playbooks.
--check against localhost with the stub: every validation refusal fires with its message; the 404, deleted and 403 lookups fire too. The DNS guard fires and the token does not appear in its output. --tags update reaches the staged download and _binary_update. The mint guards hold and nothing is POSTed in check mode.
Two independent reviews, one against the source role and one against roles/AGENTS.md, found nothing blocking. For the existing consumer, the rendered config.yml, the credentials file and the unit file are byte-identical to the source role, so the first run does not restart the tunnel.
Not verified
The first Molecule run. There is no local container runtime, so this PR's CI is the first run and a fix commit is likely.
The cloudflare_dns create, prune and delete calls: the module hard-codes the API URL, so they cannot reach the stub. That also leaves out prune paging past page 1 and the case-insensitive allowlist.
The mint child playbook needs openssl on the molecule runner.
For consumers upgrading
List mortis.kamino.cloudflared in services and in the mint play's include_role.
Old pre-rename variable names are now silently ignored.
A removal no longer reinstalls the daemon.
The checks in validate.yml run under every tag, --tags update included.
Follow-ups (left out on purpose: each one changes rendered files and restarts the tunnel)
Add --no-autoupdate, hardening directives and network-online.target to the unit.
Make root:cloudflared own the config files, with 0640 files and a 0750 directory.
Quote wildcard hostnames with to_json in config.yml.
Page the per-hostname DNS lookup. Today it reads one page of 100 records per hostname.
Assisted-by: Claude Code:claude-opus-5-5
Adds `cloudflared`, a Cloudflare Tunnel daemon role with a `mint` entry point. It is the fourth role to call `_binary_update`, after `gitea`, `gitea_runner` and `traefik`. The role is ported from the maintainer's local role, with the changes listed below. It is the wave 2 extraction, so it is removed from the README Roadmap.
## What changed compared with the source role
- **Updates.** The role still stages the download and checks its sha256. Stop, backup, swap, restart, version check and rollback now run in `mortis.kamino._binary_update`, included with `apply` tags, so `--tags update` reaches the download. The cloudflared-specific stale-sha guard and the `0.0.0` handling stay in the role.
- **`tasks/validate.yml`** (tag `always`). It checks the version and sha format. Ingress hostnames must be lowercase, may start with `*.`, and must not contain whitespace or a newline. The user, group and directories must not contain a newline or `%`, and the directories must be absolute paths. The tunnel id must be a UUID. The secrets and, when DNS is managed, the zone are checked before any change.
- **Exception to "a secret is a required input."** The tunnel id, credentials, account id and API token are not `required: true`. When one is missing, the role's own assert tells the operator to run the `mint` entry point, and that is the only way the first run on a new host can work. The reason is written in both `argument_specs` and the README. `mint` keeps the generated secret in no_log facts only. Persisting it is the consumer's job, as in `gitea`'s mint.
- **New input `cloudflared_manage_dns`** (default `true`). With `false`, every DNS call is skipped.
- **DNS handling:**
- the overwrite guard queries one hostname at a time with the name urlencoded;
- hostnames compare case-insensitively;
- the prune pages through `result_info.total_pages`;
- `config.yml` is checked with `ingress validate` before it is written.
- **Fixes to behaviour carried over from the source role:**
- A 404 or a deleted tunnel now reaches the re-mint message. Before, it failed inside a hidden `no_log` task. Any other status fails with its HTTP code.
- A removal now ends the role, as in `gitea_runner`; before, the same run reinstalled the daemon.
- The mint block runs with `become: false` and checks the account id, token and tunnel name before it creates anything.
- **Dropped:** the legacy-name guards.
- **Renamed:** internal names now use `__cloudflared_*`, and the handler is now `Restart cloudflared`.
- **Moved:** the meta namespace is now `mortis`.
- **Docs:** changelog fragment `changelogs/fragments/cloudflared-role.yml` (minor_changes), the README status line, the list of `_binary_update` callers, and the Roadmap.
- `galaxy.yml` is not bumped. The release is a separate PR.
## Molecule (`molecule/default`)
- A `file://` download and a local Cloudflare API stub (`files/cloudflare_api_stub.py`, bound to 127.0.0.1 on a random port, exits after 1500 s).
- Covers install, configure, the update through `_binary_update`, the lookup failures (404, deleted, other status), the input refusals, and `mint` (confirm guard, CI refusal, generation in memory).
- The cleanup stops the stub only if the pid still belongs to the stub.
- No `check` step, as in `gitea_runner` (#134).
## Scrub check
I grepped the diff and the commit messages for the #293 terms: domain, hosts and groups, private IPs, issue references to the other repo, its paths, and tunnel words. The remaining hits are intentional: `mortis.kamino.*` names, `namespace`/`author` in meta, the scenario's `group_vars` key and its own `mint.yml`. Test data uses only `example.test`/`example.com`, 192.0.2.10 and dummy UUIDs.
## Verified (locally)
- All commit and pre-push hooks pass, including ansible-lint (production profile), yamllint, ruff, REUSE, the changelog lint and gitleaks.
- `ansible-test sanity`: 0 errors, pylint and pep8 included on the stub.
- `tests/scripts`: 243 tests pass.
- `--syntax-check` passes on the 5 scenario playbooks.
- `--check` against localhost with the stub: every validation refusal fires with its message; the 404, deleted and 403 lookups fire too. The DNS guard fires and the token does not appear in its output. `--tags update` reaches the staged download and `_binary_update`. The mint guards hold and nothing is POSTed in check mode.
- Two independent reviews, one against the source role and one against `roles/AGENTS.md`, found nothing blocking. For the existing consumer, the rendered `config.yml`, the credentials file and the unit file are byte-identical to the source role, so the first run does not restart the tunnel.
## Not verified
- The first Molecule run. There is no local container runtime, so this PR's CI is the first run and a fix commit is likely.
- The `cloudflare_dns` create, prune and delete calls: the module hard-codes the API URL, so they cannot reach the stub. That also leaves out prune paging past page 1 and the case-insensitive allowlist.
- The mint child playbook needs `openssl` on the molecule runner.
## For consumers upgrading
- List `mortis.kamino.cloudflared` in `services` and in the mint play's `include_role`.
- Old pre-rename variable names are now silently ignored.
- A removal no longer reinstalls the daemon.
- The checks in `validate.yml` run under every tag, `--tags update` included.
## Follow-ups (left out on purpose: each one changes rendered files and restarts the tunnel)
- Add `--no-autoupdate`, hardening directives and `network-online.target` to the unit.
- Make `root:cloudflared` own the config files, with 0640 files and a 0750 directory.
- Quote wildcard hostnames with `to_json` in `config.yml`.
- Page the per-hostname DNS lookup. Today it reads one page of 100 records per hostname.
Assisted-by: Claude Code:claude-opus-5-5
Installs cloudflared as a systemd service for a locally managed
Cloudflare Tunnel: checks that the tunnel exists, manages its proxied
CNAMEs, renders config.yml and the credentials file, and updates the
binary through the internal _binary_update role. The opt-in mint entry
point creates the tunnel and registers its id and credentials as no_log
facts for the calling play to persist.
Validation runs first under always and asserts the tunnel secrets with
the mint instructions; the secrets stay optional in the argument spec on
purpose. cloudflared_manage_dns lets the records be managed elsewhere.
A removal now ends the role.
Assisted-by: Claude Code:claude-opus-5-5
Runs without Cloudflare and without a real cloudflared: a stub of the
Cloudflare API on the controller's loopback answers the tunnel, zone and
DNS record calls through cloudflared_api_base_url, a stub binary stands
in for the daemon, and the releases come from file:// URLs.
Covers the converge with an update through _binary_update and its
idempotence, the rendered files and the running unit, the input asserts,
the deleted-tunnel and DNS guards, a stale hash and a failed checksum,
the mint entry point (as child processes outside CI) and the remove
path. The cloudflare_dns calls cannot reach the stub and are not run.
Assisted-by: Claude Code:claude-opus-5-5
The role is in the Collection now, so it leaves the wave 2 Roadmap
line, and the status line names it as an unreleased caller of the
internal _binary_update role.
Assisted-by: Claude Code:claude-opus-5-5
A lookup that still returned 404 after its retries failed the lookup
task itself, whose output no_log hides, so the message with the re-mint
steps never ran. The lookup now ignores its own failure; the next task
fails with the re-mint steps for a 404 or a deleted tunnel, and a new
one fails with the HTTP status for any other lookup error.
Assisted-by: Claude Code:claude-opus-5-5
Ingress hostnames must be lowercase, with an optional leading *. and no
whitespace: they land unquoted in config.yml. The service account names
and directories must hold no newline or %, which the unit would read as
directives, and the directories must be absolute. A set tunnel id must
be a lowercase UUID, the shape the stale-credentials search relies on.
Each refusal has a negative case in the scenario.
Assisted-by: Claude Code:claude-opus-5-5
The overwrite guard listed the zone's first 100 records only, so a
record further on went unseen. It now queries each ingress hostname by
name and compares names case-insensitively, and the prune listing pages
through result_info.total_pages. Query values are urlencoded. The
template task validates config.yml with cloudflared before it replaces
the file; the rendered content is unchanged. The API stub filters by
name and pages to match.
Assisted-by: Claude Code:claude-opus-5-5
Cleanup now checks /proc/<pid>/cmdline before it signals the pid, so a
reused pid is never killed, and removes the pid file afterwards.
Assisted-by: Claude Code:claude-opus-5-5
molecule interpolates environment variables in molecule.yml, so `$1`
and `$*` in the embedded stub script failed the config parse ("Invalid
placeholder") before any step ran. `$$` renders as a literal `$`.
Assisted-by: Claude Code:claude-opus-5-5
The plain scalar `cloudflared_test_posts[0] is search('"status": 200')`
holds ': ', so YAML parsed it as a one-key mapping and ansible-core
refused it ("Conditional expressions must be strings"). A folded block
scalar keeps it a string.
Assisted-by: Claude Code:claude-opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Adds
cloudflared, a Cloudflare Tunnel daemon role with amintentry point. It is the fourth role to call_binary_update, aftergitea,gitea_runnerandtraefik. The role is ported from the maintainer's local role, with the changes listed below. It is the wave 2 extraction, so it is removed from the README Roadmap.What changed compared with the source role
mortis.kamino._binary_update, included withapplytags, so--tags updatereaches the download. The cloudflared-specific stale-sha guard and the0.0.0handling stay in the role.tasks/validate.yml(tagalways). It checks the version and sha format. Ingress hostnames must be lowercase, may start with*., and must not contain whitespace or a newline. The user, group and directories must not contain a newline or%, and the directories must be absolute paths. The tunnel id must be a UUID. The secrets and, when DNS is managed, the zone are checked before any change.required: true. When one is missing, the role's own assert tells the operator to run themintentry point, and that is the only way the first run on a new host can work. The reason is written in bothargument_specsand the README.mintkeeps the generated secret in no_log facts only. Persisting it is the consumer's job, as ingitea's mint.cloudflared_manage_dns(defaulttrue). Withfalse, every DNS call is skipped.result_info.total_pages;config.ymlis checked withingress validatebefore it is written.no_logtask. Any other status fails with its HTTP code.gitea_runner; before, the same run reinstalled the daemon.become: falseand checks the account id, token and tunnel name before it creates anything.__cloudflared_*, and the handler is nowRestart cloudflared.mortis.changelogs/fragments/cloudflared-role.yml(minor_changes), the README status line, the list of_binary_updatecallers, and the Roadmap.galaxy.ymlis not bumped. The release is a separate PR.Molecule (
molecule/default)file://download and a local Cloudflare API stub (files/cloudflare_api_stub.py, bound to 127.0.0.1 on a random port, exits after 1500 s)._binary_update, the lookup failures (404, deleted, other status), the input refusals, andmint(confirm guard, CI refusal, generation in memory).checkstep, as ingitea_runner(#134).Scrub check
I grepped the diff and the commit messages for the #293 terms: domain, hosts and groups, private IPs, issue references to the other repo, its paths, and tunnel words. The remaining hits are intentional:
mortis.kamino.*names,namespace/authorin meta, the scenario'sgroup_varskey and its ownmint.yml. Test data uses onlyexample.test/example.com, 192.0.2.10 and dummy UUIDs.Verified (locally)
ansible-test sanity: 0 errors, pylint and pep8 included on the stub.tests/scripts: 243 tests pass.--syntax-checkpasses on the 5 scenario playbooks.--checkagainst localhost with the stub: every validation refusal fires with its message; the 404, deleted and 403 lookups fire too. The DNS guard fires and the token does not appear in its output.--tags updatereaches the staged download and_binary_update. The mint guards hold and nothing is POSTed in check mode.roles/AGENTS.md, found nothing blocking. For the existing consumer, the renderedconfig.yml, the credentials file and the unit file are byte-identical to the source role, so the first run does not restart the tunnel.Not verified
cloudflare_dnscreate, prune and delete calls: the module hard-codes the API URL, so they cannot reach the stub. That also leaves out prune paging past page 1 and the case-insensitive allowlist.opensslon the molecule runner.For consumers upgrading
mortis.kamino.cloudflaredinservicesand in the mint play'sinclude_role.validate.ymlrun under every tag,--tags updateincluded.Follow-ups (left out on purpose: each one changes rendered files and restarts the tunnel)
--no-autoupdate, hardening directives andnetwork-online.targetto the unit.root:cloudflaredown the config files, with 0640 files and a 0750 directory.to_jsoninconfig.yml.Assisted-by: Claude Code:claude-opus-5-5
molecule interpolates environment variables in molecule.yml, so `$1` and `$*` in the embedded stub script failed the config parse ("Invalid placeholder") before any step ran. `$$` renders as a literal `$`. Assisted-by: Claude Code:claude-opus-5-5New commits pushed, approval review dismissed automatically according to repository settings
The plain scalar `cloudflared_test_posts[0] is search('"status": 200')` holds ': ', so YAML parsed it as a one-key mapping and ansible-core refused it ("Conditional expressions must be strings"). A folded block scalar keeps it a string. Assisted-by: Claude Code:claude-opus-5-5