Spec: openbao role (single-node OpenBao server) #535

Open
opened 2026-12-06 20:35:44 +00:00 by Claude · 0 comments
Owner

Decisions recorded in docs PR #533 (Secrets rule for opt-in output facts, Roadmap entry, accepted risk for unseal keys in vaulted inventory).

Problem Statement

A consumer of this Collection who wants a self-hosted secret store has no role for it. Installing OpenBao by hand means choosing a storage backend, writing a sandboxed unit, wiring TLS, initialising the server, keeping the init output safe, unsealing after every restart and upgrading without a downgrade path, all with nothing tested and nothing repeatable. The upstream .deb package does not help: it starts on a default single-file backend listening on all addresses with a self-generated certificate the consumer does not control.

Solution

A public role openbao that takes a host from nothing to a running, audited OpenBao server on integrated raft storage, with TLS the consumer supplies. Three entry points:

  • main converges the host: binary, user, unit, config, audit device, logrotate; unseals when the consumer supplies vaulted unseal keys, otherwise leaves the server sealed and warns.
  • init (opt-in) initialises an uninitialised server once and returns the unseal keys and root token as a no_log output fact, for the calling play to vault-encrypt into inventory.
  • update moves to a new pinned version: copies the raft data while stopped, swaps the binary with rollback, then unseals again or warns.

Configuration inside OpenBao (auth methods, policies, secret engines, PKI) is not this role's job; it belongs to the follow-up role in #530.

User Stories

  1. As a consumer, I want to install OpenBao with one role, so that a secret store is part of my normal Ansible run.
  2. As a consumer, I want the role to install a pinned OpenBao version, so that two runs on two hosts give the same binary.
  3. As a consumer, I want the download checked against a sha256 pinned in the role defaults, so that a tampered or replaced release asset fails the run.
  4. As a consumer, I want to override the version and its checksum together, so that I can move ahead of the role's pin when a security release lands.
  5. As a consumer, I want OpenBao to run as a dedicated system user with no login shell, so that a compromise of the service does not give a usable account.
  6. As a consumer, I want the role to ship its own sandboxed systemd unit, so that the service runs with a minimal capability set, no swap and a read-only system.
  7. As a consumer, I want integrated raft storage with a node id, cluster address and API address set, so that the node can later join a cluster without a storage migration (#528).
  8. As a consumer, I want the role to require TLS on the listener, so that tokens and secrets never cross the network in plaintext.
  9. As a consumer, I want to supply the certificate, key and CA file paths myself, so that the role never generates key material I do not control.
  10. As a consumer, I want the role to fail before any change when a TLS input is missing, so that I never get a half-configured server.
  11. As a consumer, I want to turn TLS off only through an explicit switch that warns, so that plain HTTP is never an accident.
  12. As a consumer, I want to set the listener address and port, so that the server binds only where I intend.
  13. As a consumer, I want the role to reach its own API on loopback with certificate validation against my CA, so that init and unseal do not depend on DNS and do not skip verification.
  14. As a consumer, I want the README to tell me my certificate must cover 127.0.0.1, so that I know why validation fails if it does not.
  15. As a consumer, I want a file audit device on by default through the server config, so that every request is logged from the first unseal without an API call.
  16. As a consumer, I want to switch the audit device off, so that I can use another audit backend.
  17. As a consumer, I want the audit log rotated, with OpenBao told to reopen the file, so that the log does not fill the disk and no lines are lost.
  18. As a consumer, I want the README to warn that a blocked audit device makes OpenBao refuse requests, so that I monitor disk space on the audit path.
  19. As a consumer, I want to run init only when I explicitly confirm it, so that a routine run never initialises a server.
  20. As a consumer, I want init to refuse to run in CI, so that unseal keys never appear in a CI job.
  21. As a consumer, I want init to do nothing on an already initialised server, so that running it twice is safe.
  22. As a consumer, I want init to return the unseal keys and root token as one no_log, non-cacheable fact, so that my play can vault-encrypt it and nothing is written to disk.
  23. As a consumer, I want to set the number of key shares and the threshold, so that the split matches the number of people holding keys.
  24. As a consumer, I want the README to tell me lost init output is unrecoverable, so that I persist the fact in the same play.
  25. As a consumer, I want main to unseal the server when I supply vaulted unseal keys, so that a restart or reboot does not leave the store down.
  26. As a consumer, I want the unseal keys sent only in request bodies, so that they never show in the host's process list.
  27. As a consumer, I want main without unseal keys to leave the server sealed and say so clearly, so that I can keep keys off the controller and unseal by hand.
  28. As a consumer, I want update to copy the raft data directory while the service is stopped, so that a failed upgrade can be rolled back with matching data.
  29. As a consumer, I want update to roll back both the binary and the data when the new version fails to start or reports the wrong version, so that a bad upgrade leaves the old server running.
  30. As a consumer, I want update to unseal again or warn loudly afterwards, so that an upgrade never silently leaves the store sealed.
  31. As a consumer, I want old data copies left in place and documented, so that I decide when to delete them.
  32. As a consumer, I want --check to preview every entry point without changing the host, so that I can review a run before applying it.
  33. As a consumer, I want a second run of main to report no changes, so that I can run it on a schedule.
  34. As a consumer, I want every validation to fail with a clear message before any change, so that a wrong input never half-applies.
  35. As a consumer on Ubuntu 24.04 or 26.04, I want the role tested on my release, so that a declared platform is one that works.
  36. As a consumer on Debian trixie, I want the README to say the role is untested there, so that I know the risk.
  37. As a consumer who puts a reverse proxy in front, I want the README to say the proxy must re-encrypt to the listener and that client-certificate auth needs the TLS connection itself, so that I do not terminate TLS where secrets are visible.
  38. As a consumer, I want the README to list the follow-ups (#528, #529, #530, #531, #532), so that I know what the role does not do yet.
  39. As a maintainer, I want the role to follow the Collection's role rules (layout, argument_specs, validation first, internal names, README headings), so that it reads like every other role.
  40. As a maintainer, I want the release pin in role defaults with its sha256, so that a version bump is a reviewed change.
  41. As a maintainer, I want one Molecule scenario to cover every entry point against a real OpenBao, so that CI proves the server actually starts, initialises and unseals.
  42. As a reviewer, I want every task that carries a secret marked no_log, so that no secret reaches task output or logs.

Implementation Decisions

  • New public role openbao with three supported entry points, each with its own argument_specs key, its own validation before any change and an "Entry points" README entry: main, init, update. meta dependencies stay empty; _binary_update is used by FQCN through a task-level include.
  • Install from the upstream release tarball, not the .deb. Defaults pin a version and its sha256; the download is checked by get_url with that checksum. The .deb is rejected because it ships the config as a conffile (apt prompts on upgrade), generates a self-signed key in its postinst, can start on its default backend before the role writes its config, and bypasses _binary_update's rollback.
  • The role ships its own system user and group (no shell), data directory (mode 0700), config file and systemd unit. The unit is Type=notify, stops with SIGINT, has MemorySwapMax=0 in place of mlock (removed from OpenBao in 2.0; no CAP_IPC_LOCK, no disable_mlock), and a sandboxing set modelled on the traefik role's unit plus ReadWritePaths for the data and audit directories; directives that break the service are dropped after testing. It has an ExecReload that sends SIGHUP.
  • Config: storage "raft" with path and node id; cluster_addr and api_addr set; one TCP listener with tls_cert_file, tls_key_file, a minimum TLS version input; UI off by default.
  • TLS inputs: certificate, key and CA file paths are required unless openbao_tls_disable: true, which validate.yml accepts with a warning. The role does not generate or copy key material; it checks the files exist and are readable by the service user.
  • The role calls its own API at https://127.0.0.1:<port> with validate_certs against the CA file, through ansible.builtin.uri: seal status (no auth), init, unseal. Unseal keys go only in POST bodies, never as bao arguments.
  • Audit: a declarative audit stanza in the server config creates a file device at the audit log path when openbao_audit_file_enabled is true (default). logrotate rotates it and signals OpenBao through the unit's reload.
  • init follows the Collection's opt-in output-fact pattern (gitea and cloudflared mint; rule clarified in #533): a confirm flag defaulting to false; refusal when CI variables are set; a no-op when the server reports initialised; skipped under --check; no_log on every task; key shares and threshold as inputs; the result returned as one documented output fact holding the unseal keys and root token; intermediates blanked.
  • openbao_unseal_keys is an optional, no_log input with no default. When given, main (and update) submit keys until seal status reports unsealed; when absent and the server is sealed, the role warns and continues.
  • update: validate; stop the service; copy the raft data directory to <path>.pre-<old version>; stage the verified new binary next to the live one; include _binary_update; on rollback, restore the data copy before the old binary starts; then unseal or warn. Old copies are not removed.
  • Output facts carry openbao_; everything else the role sets or registers is __openbao_.
  • Platforms: declare Ubuntu noble and resolute; Debian trixie only in a README "Untested platforms" line until the Debian test image exists.
  • Housekeeping in the same change: README role list and release status line, galaxy description, a Molecule timeout entry for the scenario, removal of openbao from the README Roadmap, and a minor_changes changelog fragment.

Testing Decisions

  • A good test asserts the effect on the host through the role's public interface: the service is active, the API answers over TLS, seal status reports what the step should leave. It does not assert rendered files alone or internal task names.
  • One seam: the role's entry points, driven by one Molecule default scenario on the noble and resolute containers against a real OpenBao. No unit tests and no new seam.
  • Prepare builds a throwaway CA and a server certificate covering 127.0.0.1 with the openssl CLI (no new Collection dependency), and applies the container drop-in that relaxes sandboxing the containers cannot provide, as the traefik and ufw scenarios do.
  • Converge runs main without unseal keys; the scenario runs --check before and after converge, and idempotence holds with the server left uninitialised and sealed.
  • Verify: runs init as a child playbook with CI variables blanked (cloudflared's mint test pattern), asserts the fact's shape under no_log and that intermediates are blank; re-runs main with the returned keys and asserts unsealed through seal status; asserts the audit device writes to the audit log; runs update against a file:// stand-in for the next version (traefik's pattern) and asserts the new version, the data copy and the unsealed state; runs init again and asserts a no-op.
  • Negative tests for every validation (missing TLS inputs, TLS disabled warning path, init without confirm, init under CI variables, bad shares/threshold), block/rescue/assert on the expected message, run last or failing before any change.
  • Prior art: the gitea and cloudflared scenarios (mint guards, child-process mint), the traefik scenario (binary download, sandboxing drop-in, file:// update), _binary_update's scenarios (swap and rollback).

Out of Scope

  • Multi-node HA: #528.
  • Auto-unseal (transit, static, KMS) and declarative self-initialisation, which needs auto-unseal: #529.
  • Configuration through OpenBao's API (auth methods, policies, secret engines, PKI engine and its ACME directory): #530.
  • Installing a root CA into system trust stores: #531.
  • Automated certificate issuance, including re-issuing OpenBao's own listener certificate from its PKI and Traefik's ACME CA input: #532.
  • A dependency on or call to the traefik role; generating any TLS material.
  • Raft snapshots through the API (they need a token the role does not hold).

Further Notes

Accepted trade-offs:

  • Unseal keys in vaulted inventory weaken Shamir's split knowledge: whoever holds the vault password can unseal alone. Accepted for unattended restarts and updates; the keys are optional, and #529 offers auto-unseal. Recorded as an accepted risk in #533.
  • Version bumps are manual and frequent: upstream ships patch releases every one to four weeks, mostly security fixes, and Renovate does not track role binary pins.
  • A file audit device that cannot write blocks every request; the README tells the consumer to monitor the audit path's disk space.

Facts to confirm during implementation: the exact JSON field names of the init response, the minimum OpenBao version for the declarative audit stanza (the pin, 2.7.3 at the time of writing, is expected to have it), and which sandboxing directives OpenBao tolerates.

Assisted-by: Claude Code

Decisions recorded in docs PR #533 (Secrets rule for opt-in output facts, Roadmap entry, accepted risk for unseal keys in vaulted inventory). ## Problem Statement A consumer of this Collection who wants a self-hosted secret store has no role for it. Installing OpenBao by hand means choosing a storage backend, writing a sandboxed unit, wiring TLS, initialising the server, keeping the init output safe, unsealing after every restart and upgrading without a downgrade path, all with nothing tested and nothing repeatable. The upstream `.deb` package does not help: it starts on a default single-file backend listening on all addresses with a self-generated certificate the consumer does not control. ## Solution A public role `openbao` that takes a host from nothing to a running, audited OpenBao server on integrated raft storage, with TLS the consumer supplies. Three entry points: - `main` converges the host: binary, user, unit, config, audit device, logrotate; unseals when the consumer supplies vaulted unseal keys, otherwise leaves the server sealed and warns. - `init` (opt-in) initialises an uninitialised server once and returns the unseal keys and root token as a `no_log` output fact, for the calling play to vault-encrypt into inventory. - `update` moves to a new pinned version: copies the raft data while stopped, swaps the binary with rollback, then unseals again or warns. Configuration inside OpenBao (auth methods, policies, secret engines, PKI) is not this role's job; it belongs to the follow-up role in #530. ## User Stories 1. As a consumer, I want to install OpenBao with one role, so that a secret store is part of my normal Ansible run. 2. As a consumer, I want the role to install a pinned OpenBao version, so that two runs on two hosts give the same binary. 3. As a consumer, I want the download checked against a sha256 pinned in the role defaults, so that a tampered or replaced release asset fails the run. 4. As a consumer, I want to override the version and its checksum together, so that I can move ahead of the role's pin when a security release lands. 5. As a consumer, I want OpenBao to run as a dedicated system user with no login shell, so that a compromise of the service does not give a usable account. 6. As a consumer, I want the role to ship its own sandboxed systemd unit, so that the service runs with a minimal capability set, no swap and a read-only system. 7. As a consumer, I want integrated raft storage with a node id, cluster address and API address set, so that the node can later join a cluster without a storage migration (#528). 8. As a consumer, I want the role to require TLS on the listener, so that tokens and secrets never cross the network in plaintext. 9. As a consumer, I want to supply the certificate, key and CA file paths myself, so that the role never generates key material I do not control. 10. As a consumer, I want the role to fail before any change when a TLS input is missing, so that I never get a half-configured server. 11. As a consumer, I want to turn TLS off only through an explicit switch that warns, so that plain HTTP is never an accident. 12. As a consumer, I want to set the listener address and port, so that the server binds only where I intend. 13. As a consumer, I want the role to reach its own API on loopback with certificate validation against my CA, so that init and unseal do not depend on DNS and do not skip verification. 14. As a consumer, I want the README to tell me my certificate must cover `127.0.0.1`, so that I know why validation fails if it does not. 15. As a consumer, I want a file audit device on by default through the server config, so that every request is logged from the first unseal without an API call. 16. As a consumer, I want to switch the audit device off, so that I can use another audit backend. 17. As a consumer, I want the audit log rotated, with OpenBao told to reopen the file, so that the log does not fill the disk and no lines are lost. 18. As a consumer, I want the README to warn that a blocked audit device makes OpenBao refuse requests, so that I monitor disk space on the audit path. 19. As a consumer, I want to run `init` only when I explicitly confirm it, so that a routine run never initialises a server. 20. As a consumer, I want `init` to refuse to run in CI, so that unseal keys never appear in a CI job. 21. As a consumer, I want `init` to do nothing on an already initialised server, so that running it twice is safe. 22. As a consumer, I want `init` to return the unseal keys and root token as one `no_log`, non-cacheable fact, so that my play can vault-encrypt it and nothing is written to disk. 23. As a consumer, I want to set the number of key shares and the threshold, so that the split matches the number of people holding keys. 24. As a consumer, I want the README to tell me lost init output is unrecoverable, so that I persist the fact in the same play. 25. As a consumer, I want `main` to unseal the server when I supply vaulted unseal keys, so that a restart or reboot does not leave the store down. 26. As a consumer, I want the unseal keys sent only in request bodies, so that they never show in the host's process list. 27. As a consumer, I want `main` without unseal keys to leave the server sealed and say so clearly, so that I can keep keys off the controller and unseal by hand. 28. As a consumer, I want `update` to copy the raft data directory while the service is stopped, so that a failed upgrade can be rolled back with matching data. 29. As a consumer, I want `update` to roll back both the binary and the data when the new version fails to start or reports the wrong version, so that a bad upgrade leaves the old server running. 30. As a consumer, I want `update` to unseal again or warn loudly afterwards, so that an upgrade never silently leaves the store sealed. 31. As a consumer, I want old data copies left in place and documented, so that I decide when to delete them. 32. As a consumer, I want `--check` to preview every entry point without changing the host, so that I can review a run before applying it. 33. As a consumer, I want a second run of `main` to report no changes, so that I can run it on a schedule. 34. As a consumer, I want every validation to fail with a clear message before any change, so that a wrong input never half-applies. 35. As a consumer on Ubuntu 24.04 or 26.04, I want the role tested on my release, so that a declared platform is one that works. 36. As a consumer on Debian trixie, I want the README to say the role is untested there, so that I know the risk. 37. As a consumer who puts a reverse proxy in front, I want the README to say the proxy must re-encrypt to the listener and that client-certificate auth needs the TLS connection itself, so that I do not terminate TLS where secrets are visible. 38. As a consumer, I want the README to list the follow-ups (#528, #529, #530, #531, #532), so that I know what the role does not do yet. 39. As a maintainer, I want the role to follow the Collection's role rules (layout, argument_specs, validation first, internal names, README headings), so that it reads like every other role. 40. As a maintainer, I want the release pin in role defaults with its sha256, so that a version bump is a reviewed change. 41. As a maintainer, I want one Molecule scenario to cover every entry point against a real OpenBao, so that CI proves the server actually starts, initialises and unseals. 42. As a reviewer, I want every task that carries a secret marked `no_log`, so that no secret reaches task output or logs. ## Implementation Decisions - New public role `openbao` with three supported entry points, each with its own argument_specs key, its own validation before any change and an "Entry points" README entry: `main`, `init`, `update`. `meta` dependencies stay empty; `_binary_update` is used by FQCN through a task-level include. - Install from the upstream release tarball, not the `.deb`. Defaults pin a version and its sha256; the download is checked by `get_url` with that checksum. The `.deb` is rejected because it ships the config as a conffile (apt prompts on upgrade), generates a self-signed key in its postinst, can start on its default backend before the role writes its config, and bypasses `_binary_update`'s rollback. - The role ships its own system user and group (no shell), data directory (mode 0700), config file and systemd unit. The unit is `Type=notify`, stops with SIGINT, has `MemorySwapMax=0` in place of mlock (removed from OpenBao in 2.0; no `CAP_IPC_LOCK`, no `disable_mlock`), and a sandboxing set modelled on the traefik role's unit plus `ReadWritePaths` for the data and audit directories; directives that break the service are dropped after testing. It has an `ExecReload` that sends SIGHUP. - Config: `storage "raft"` with path and node id; `cluster_addr` and `api_addr` set; one TCP listener with `tls_cert_file`, `tls_key_file`, a minimum TLS version input; UI off by default. - TLS inputs: certificate, key and CA file paths are required unless `openbao_tls_disable: true`, which `validate.yml` accepts with a warning. The role does not generate or copy key material; it checks the files exist and are readable by the service user. - The role calls its own API at `https://127.0.0.1:<port>` with `validate_certs` against the CA file, through `ansible.builtin.uri`: seal status (no auth), init, unseal. Unseal keys go only in POST bodies, never as `bao` arguments. - Audit: a declarative `audit` stanza in the server config creates a file device at the audit log path when `openbao_audit_file_enabled` is true (default). logrotate rotates it and signals OpenBao through the unit's reload. - `init` follows the Collection's opt-in output-fact pattern (gitea and cloudflared `mint`; rule clarified in #533): a confirm flag defaulting to false; refusal when CI variables are set; a no-op when the server reports initialised; skipped under `--check`; `no_log` on every task; key shares and threshold as inputs; the result returned as one documented output fact holding the unseal keys and root token; intermediates blanked. - `openbao_unseal_keys` is an optional, `no_log` input with no default. When given, `main` (and `update`) submit keys until seal status reports unsealed; when absent and the server is sealed, the role warns and continues. - `update`: validate; stop the service; copy the raft data directory to `<path>.pre-<old version>`; stage the verified new binary next to the live one; include `_binary_update`; on rollback, restore the data copy before the old binary starts; then unseal or warn. Old copies are not removed. - Output facts carry `openbao_`; everything else the role sets or registers is `__openbao_`. - Platforms: declare Ubuntu `noble` and `resolute`; Debian `trixie` only in a README "Untested platforms" line until the Debian test image exists. - Housekeeping in the same change: README role list and release status line, galaxy description, a Molecule timeout entry for the scenario, removal of `openbao` from the README Roadmap, and a `minor_changes` changelog fragment. ## Testing Decisions - A good test asserts the effect on the host through the role's public interface: the service is active, the API answers over TLS, seal status reports what the step should leave. It does not assert rendered files alone or internal task names. - One seam: the role's entry points, driven by one Molecule default scenario on the noble and resolute containers against a real OpenBao. No unit tests and no new seam. - Prepare builds a throwaway CA and a server certificate covering `127.0.0.1` with the `openssl` CLI (no new Collection dependency), and applies the container drop-in that relaxes sandboxing the containers cannot provide, as the traefik and ufw scenarios do. - Converge runs `main` without unseal keys; the scenario runs `--check` before and after converge, and idempotence holds with the server left uninitialised and sealed. - Verify: runs `init` as a child playbook with CI variables blanked (cloudflared's mint test pattern), asserts the fact's shape under `no_log` and that intermediates are blank; re-runs `main` with the returned keys and asserts unsealed through seal status; asserts the audit device writes to the audit log; runs `update` against a `file://` stand-in for the next version (traefik's pattern) and asserts the new version, the data copy and the unsealed state; runs `init` again and asserts a no-op. - Negative tests for every validation (missing TLS inputs, TLS disabled warning path, `init` without confirm, `init` under CI variables, bad shares/threshold), block/rescue/assert on the expected message, run last or failing before any change. - Prior art: the gitea and cloudflared scenarios (mint guards, child-process mint), the traefik scenario (binary download, sandboxing drop-in, `file://` update), `_binary_update`'s scenarios (swap and rollback). ## Out of Scope - Multi-node HA: #528. - Auto-unseal (transit, static, KMS) and declarative self-initialisation, which needs auto-unseal: #529. - Configuration through OpenBao's API (auth methods, policies, secret engines, PKI engine and its ACME directory): #530. - Installing a root CA into system trust stores: #531. - Automated certificate issuance, including re-issuing OpenBao's own listener certificate from its PKI and Traefik's ACME CA input: #532. - A dependency on or call to the traefik role; generating any TLS material. - Raft snapshots through the API (they need a token the role does not hold). ## Further Notes Accepted trade-offs: - Unseal keys in vaulted inventory weaken Shamir's split knowledge: whoever holds the vault password can unseal alone. Accepted for unattended restarts and updates; the keys are optional, and #529 offers auto-unseal. Recorded as an accepted risk in #533. - Version bumps are manual and frequent: upstream ships patch releases every one to four weeks, mostly security fixes, and Renovate does not track role binary pins. - A file audit device that cannot write blocks every request; the README tells the consumer to monitor the audit path's disk space. Facts to confirm during implementation: the exact JSON field names of the init response, the minimum OpenBao version for the declarative audit stanza (the pin, 2.7.3 at the time of writing, is expected to have it), and which sandboxing directives OpenBao tolerates. Assisted-by: Claude Code
Claude added the Kind/Feature
Status
Ready for Agent
labels 2026-12-06 20:35:44 +00:00
Claude added this to the openbao role milestone 2026-12-06 20:42:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#535