A consumer gets a running single-node OpenBao server on integrated raft storage, listening on TLS they supply, left uninitialised and sealed. The role installs the pinned 2.7.3 release tarball, checked by get_url against the sha256 of each architecture from the release's checksums.txt (its GPG signature checks out against OpenBao's release key). It creates its own system user, data directory, configuration and sandboxed unit: Type=notify, SIGINT stop, MemorySwapMax=0 instead of mlock, an empty capability set, ProtectSystem=strict with the data directory writable, and ExecReload sending SIGHUP. The directive set was tried against the real binary under systemd before it was kept. TLS certificate, key and CA paths are required unless openbao_tls_disable is true, which warns; validation fails before any change when a file is missing, and the role checks the service user can read the key and certificate before writing the config. It reads its seal status over https://127.0.0.1 validated against the CA file, so an address other than a wildcard or loopback gets a second loopback listener. The tasks are split by job (validate, prereqs, install, configure, seal_status) so the init, unseal, audit and update work can reuse them. Refs: #536 Assisted-by: Claude Code
7.6 KiB
openbao
Installs a single OpenBao server on integrated raft storage as a sandboxed systemd service, listening on TLS the consumer supplies. The role installs the pinned release tarball after checking it against a sha256 pinned in its defaults, creates its own system user, data directory, configuration and unit, starts the service and reads its seal status over TLS on loopback. It leaves a new server uninitialised and sealed. Variables and their types are defined in meta/argument_specs.yml, which is the source of truth.
Supported platforms
Ubuntu 24.04 (noble) and 26.04 (resolute), the platforms the molecule scenario runs on, on amd64 or arm64; the role needs systemd. The target needs outbound access to github.com for the release download.
Untested platforms: Debian 13 (trixie). The role uses nothing Ubuntu-specific, but no Debian test image exists yet, so it is not declared in meta/main.yml.
Requirements and run order
- Use it by its fully qualified name,
mortis.kamino.openbao. - Role dependencies: none.
- Before the first run, deploy the listener's certificate (with its chain), its private key and the CA certificate that signed it to the host, and set
openbao_tls_cert_file,openbao_tls_key_fileandopenbao_tls_ca_fileto their paths. The role never creates or copies key material. Validation fails before any change when one is unset or does not exist; the key and certificate must also be readable by theopenbaouser, which the role checks before it writes the configuration. Create theopenbaogroup first (a system group) and give it the key, for exampleroot:openbaomode0640; the role finds the group and keeps it. - The certificate must cover
127.0.0.1as an IP subject alternative name: the role reads its own API athttps://127.0.0.1:<openbao_port>and validates the certificate againstopenbao_tls_ca_file, so a certificate for the host name alone fails that check. - A firewall rule for
openbao_port(clients) andopenbao_cluster_port(raft peers) is the consumer's: the role opens no port.
Role variables
| Variable | Default | Description |
|---|---|---|
openbao_tls_cert_file |
"" (asserted unless openbao_tls_disable) |
Path of the listener certificate on the host; must cover 127.0.0.1. |
openbao_tls_key_file |
"" (asserted unless openbao_tls_disable) |
Path of the listener key on the host, readable by openbao_user. |
openbao_tls_ca_file |
"" (asserted unless openbao_tls_disable) |
Path on the host of the CA certificate the role validates the API against. |
openbao_tls_min_version |
tls12 |
tls12 or tls13. |
openbao_tls_disable |
false |
Serve plain HTTP; the TLS inputs are then not needed and the role warns on every run. |
openbao_listen_address |
0.0.0.0 |
IPv4 or IPv6 listener address. Any address other than 0.0.0.0, :: or 127.0.0.1 gets a second listener on 127.0.0.1 for the role's own calls. |
openbao_port |
8200 |
API port. |
openbao_cluster_port |
8201 |
Cluster port. |
openbao_api_addr |
https://<inventory_hostname>:<openbao_port> |
Address advertised to clients (http:// with openbao_tls_disable). |
openbao_cluster_addr |
https://<inventory_hostname>:<openbao_cluster_port> |
Address advertised to raft peers, always https://. |
openbao_node_id |
{{ inventory_hostname }} |
Raft node id. Do not change it on an initialised node. |
openbao_ui |
false |
Serve the web UI. |
openbao_version |
pinned in defaults/main.yml |
Release version, no leading v. |
openbao_sha256 |
pinned, amd64 and arm64 |
SHA-256 of the release tarball per architecture, from the release's checksums.txt. Update with the version. |
openbao_release_url |
github.com release directory of the version | URL of the directory holding openbao_<version>_linux_<arch>.tar.gz, no trailing slash. |
openbao_user, openbao_group |
openbao |
Service account, created with no login shell. |
openbao_bin_path |
/usr/local/bin/bao |
Binary location; the file name must be bao. |
openbao_config_dir |
/etc/openbao |
Configuration directory; the server reads openbao.hcl in it. |
openbao_data_dir |
/var/lib/openbao |
Raft data directory, mode 0700. |
Tags
openbao (everything), prereqs, install, configure, health. The input checks and the prereqs tasks are also tagged always. --tags health checks the TLS files' readability, the service state and the seal status without writing the configuration or the unit.
Example play
- name: Run OpenBao
hosts: secret_store
roles:
- role: mortis.kamino.openbao
vars:
openbao_tls_cert_file: /etc/ssl/openbao/server.crt
openbao_tls_key_file: /etc/ssl/openbao/server.key
openbao_tls_ca_file: /etc/ssl/openbao/ca.crt
Tests
The default molecule scenario runs in CI only, on two platforms: ${MOLECULE_IMAGE} (Ubuntu 24.04) and ${MOLECULE_IMAGE_2604} (Ubuntu 26.04). Prepare builds a throwaway CA and a server certificate covering 127.0.0.1 with the openssl CLI. The converge downloads the pinned release from GitHub and starts a real OpenBao server, left uninitialised and sealed. Verify asserts that the service is active with the unit's settings, the service user and the data directory, the installed version, the seal status over TLS validated against the test CA, a reload that keeps the server running, every input check (each failing with its own message and changing nothing), and the switch to plain HTTP and back. It runs check before the converge (a fresh host) and after it (a configured host), then idempotence.
The unprivileged test container cannot set up the unit's namespace sandboxing or switch to the service user, so prepare adds a drop-in that resets those directives and runs the unit as root there; the unit's seccomp filters, signals and MemorySwapMax stay in force. The sandbox as a whole is therefore not covered by the scenario.
Notes
- Idempotent: yes.
- The role does not initialise or unseal the server. A new server stays uninitialised and sealed, and every restart seals it again; the role warns on each run while the server is uninitialised or sealed.
- A restart runs only when the configuration, the unit or the binary changed. A change to the certificate files needs no restart:
systemctl reload openbaosends SIGHUP, which makes OpenBao read them again without sealing. - The binary is installed only when it is missing;
maindoes not change the version of an installed binary. - mlock was removed in OpenBao 2.0, so the unit sets no
CAP_IPC_LOCKand the configuration nodisable_mlock;MemorySwapMax=0keeps the server's memory out of swap andLimitCORE=0out of core dumps. The unit stops the server with SIGINT, runs with an empty capability set andProtectSystem=strict, and may write only the data directory. - A reverse proxy in front of OpenBao must re-encrypt to the listener rather than end TLS at the proxy: the proxy would see every token and secret in plain text, and TLS certificate authentication needs the client's TLS connection to reach OpenBao itself.
- TLS can be turned off only through
openbao_tls_disable, and the role warns on every such run. - Check mode:
--checkis the supported preview; a play-levelcheck_mode: trueis not supported. Under--checkon a fresh host the download, the start and the seal status read are skipped, and the readability check of the TLS files is skipped while theopenbaouser is new. - Not covered yet: multi-node raft (#528), auto-unseal (#529), configuration through OpenBao's API (#530), installing a CA into trust stores (#531) and certificate issuance (#532).