Since778c18fb23the carrier key holds the tokens file's mtime and size. sys-token-store changed that stat on every inclusion (00_core.yml touched the file) and on every persisted token, and nothing re-parked a carrier afterwards. Every later task's fresh worker then rendered the applications SPOT cold, 30 to 80 s each. On mainfea6f31d9f(run 38812964308) seven heavy jobs logged 194 to 287 such tasks and ran out of the 20400 s budget; the same jobs before778c18fb23logged 65 to 83, all of them real waits. - 00_core.yml touches the store with modification_time and access_time preserved, so it only creates a missing file. In swarm the controller sees the store over NFS with attribute caching, and the touch alone made the second pass go cold without any write. - write.yml re-parks the carrier when the persist or the controller mirror changed the store. Both run once, so every host that ran the include gets the same verdict. - tasks/utils/setup/role.yml re-parks after every role on every host, so hosts that did not run the writing role recover too. Where the key still matches this serves the carried payload; measured 0.1 s per role in a local compose deploy. - The tokens file enters the key as the SHA-256 of its content, memoised per inode, mtime and size, so a touch no longer changes the key. A stat that still matches serves the memo (1.67 us against 1.41 us for the old stat signature), and a stale stat keeps key and YAML cache on the same old content instead of pairing new content with an old key. - applications_carrier opens the tokens file before it computes the key, so on the NFS-mounted controller the parked key reflects the revalidated attributes rather than a cached stat that changes a minute later. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sys-token-store
Description
sys-token-store is a lightweight Ansible helper role for resolving and persisting per-user application tokens in a unified and idempotent way.
It provides a single source of truth for application tokens while keeping runtime usage simple and consistent across roles.
The role is intentionally not a secret generator.
It only stores and propagates tokens that already exist (e.g. created by bootstrap processes or provided externally).
Overview
This role stores and manages per-user application tokens in a local YAML store file (idempotent read/write helpers).
Cosmos
The diagram places sys-token-store in the Infinito.Nexus cosmos: the components it deploys (capabilities), the central services it consumes (dependencies), and its outward reach (federation and bridged external networks).
flowchart LR
subgraph role [sys-token-store 💻]
svc_token_store["token-store"]
end
Solid 1:1 edges are fixed relationships; dashed 0..1 edges are conditional (enabled only in matching deployments); red 0..0 edges are turned off in this role. Node markers show the role's deploy modes (💻 host, 🐳 compose, 🐝 swarm); ❌ marks a service that is explicitly turned off, and ⚙️ an Ansible role dependency declared in meta/main.yml.
Features
- Automated provisioning: Configured by Ansible without manual steps.
Core Principles
- Single logic for all roles
- Always resolve tokens as:
users → token store → empty
- Always resolve tokens as:
- No implicit token generation
- Empty tokens are rejected
- Idempotent persistence
- Store file is only rewritten when content actually changes
- Lookup-based runtime resolution
- Tokens are resolved through
lookup('users'), which hydrates from the store on each lookup call
- Tokens are resolved through
- Case-sensitive keys
- User keys and application IDs must match exactly
Token Resolution Order
When resolving a token, the following order is used:
lookup('users', '<user>').tokens.<application_id>- Token store file (
tokens.yml) - Empty string (
'')
No automatic fallback generation happens.
Store Format
Tokens are stored in a single YAML file:
users:
administrator:
tokens:
web-app-matomo: "46e50b0eb52d0d141a7d6cf9b3d0b3e2"
Default location:
/var/lib/infinito/secrets/tokens.yml
Permissions are restricted to root by default.
Provided Tasks
write.yml
Persists a token so it is available through the users lookup on subsequent reads.
This is the canonical way to store tokens.
Input
sys_token_store_user_keysys_token_store_appsys_token_store_token(must be non-empty)
Effects
- Updates the token store file (idempotent)
- Makes the token available via
lookup('users', '<user>').tokens['<app>'] - Exports
sys_token_store_token
Empty tokens are rejected explicitly.
Usage Examples
Persist a token
- include_role:
name: sys-token-store
tasks_from: write.yml
vars:
sys_token_store_user_key: administrator
sys_token_store_app: web-app-matomo
sys_token_store_token: "{{ matomo_token_value }}"
After this, the token is available as:
lookup('users', 'administrator').tokens['web-app-matomo']
What This Role Does Not Do
- ❌ No token generation
- ❌ No encryption
- ❌ No user management
- ❌ No application-specific logic
It is a generic infrastructure helper.
Best Practices
- Keep all user and application keys lowercase
- Use stable
application_idvalues - Let application roles create tokens
- Let
sys-token-storehandle persistence
Credits
Implemented by Kevin Veen-Birkenbach. Part of the Infinito.Nexus Project and maintained by Kevin Veen-Birkenbach. Licensed under the Infinito.Nexus Community License (Non-Commercial).