The readability check of the TLS certificate and key ran after the role had created the user and directories and installed the binary, so a fresh host with a key the service user cannot read was changed and then failed. It now runs in validation, from the files' owner, group and mode against openbao_user and openbao_group, before anything changes; prepare proves it on the fresh host. Also from review: - a seal status read that fails names the 127.0.0.1 IP SAN and openbao_tls_ca_file instead of a raw SSL error - :: gets the loopback listener too: it reaches 127.0.0.1 only while net.ipv6.bindv6only is 0 - the listen address check rejects strings such as ... or ::: - the TLS-disabled warning is registered, and verify asserts it - a missing binary under --skip-tags install fails with a clear message - the README names openbao_user and openbao_group and says the always tagged prereqs run under --tags health too Refs: #536 Assisted-by: Claude Code
8.2 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, does not exist, or, for the certificate and key, is not readable byopenbao_user(defaultopenbao) judging by the file's owner, group and mode; the directories above the files are not checked. Create theopenbao_groupgroup (defaultopenbao, a system group) before the first run 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, with a message naming the SAN andopenbao_tls_ca_file. - 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, including :: (which reaches IPv4 only while net.ipv6.bindv6only is 0), 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. Create the group before the first run and give it the TLS key. |
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 (including the TLS files' existence and readability) and the prereqs tasks are also tagged always, so they run under any tag selection: --tags health still creates a missing user, group or directory, then checks the binary, 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), a CA that did not sign the certificate, and the switch to plain HTTP and back with its warning. Prepare also runs the role on the fresh host with a key the service user cannot read and asserts that it changed nothing. 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. With--skip-tags installon a host without it, the role fails with that message before writing the configuration. - 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. - 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).