Files
Kamino/roles/openbao/README.md
T
Defame1297 7511d40ff8
Build / build (pull_request) Successful in 21s
Lint / renovate-config (pull_request) Successful in 4s
Molecule / select (pull_request) Successful in 3s
Lint / lint (pull_request) Successful in 5m20s
Molecule / scenarios (pull_request) Successful in 37m31s
Molecule / Result (pull_request) Successful in 1s
fix(openbao): follow TLS symlinks and keep :: on one listener
Go opens a :: listener dual-stack, so it already serves 127.0.0.1 and a
second loopback listener failed to bind with "address already in use".
:: again gets no loopback listener.

The TLS file checks did not follow symlinks, so a certbot-style live/
path was refused as not a regular file; the stat now follows them, and
the scenario reaches its certificate and key through symlinks.

Also:
- an owner or group with no name gives the readability message, not a
  templating error
- openbao_port and openbao_cluster_port must be 1024 or higher: the
  unit grants no capability to bind a lower port
- SystemCallErrorNumber=EPERM, so a filtered syscall fails instead of
  killing the server with SIGSYS
- a warning when the installed binary differs from openbao_version,
  since main does not change an installed binary
- the TLS file inputs are type path in the argument spec

Refs: #536
Assisted-by: Claude Code
2026-12-06 22:51:40 +00:00

8.5 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_file and openbao_tls_ca_file to 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 by openbao_user (default openbao) judging by the owner, group and mode of the file (behind a symlink, such as certbot's live/ paths); the directories above the files are not checked. Create the openbao_group group (default openbao, a system group) before the first run and give it the key, for example root:openbao mode 0640; the role finds the group and keeps it.
  • The certificate must cover 127.0.0.1 as an IP subject alternative name: the role reads its own API at https://127.0.0.1:<openbao_port> and validates the certificate against openbao_tls_ca_file, so a certificate for the host name alone fails that check, with a message naming the SAN and openbao_tls_ca_file.
  • A firewall rule for openbao_port (clients) and openbao_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. :: listens on every IPv4 and IPv6 address, 127.0.0.1 included. 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, 1024 or higher: the unit grants no capability to bind a lower one.
openbao_cluster_port 8201 Cluster port, 1024 or higher.
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 role reaches the certificate and key through symlinks. 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, a different openbao_version (a warning, no change), 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 openbao sends SIGHUP, which makes OpenBao read them again without sealing.
  • The binary is installed only when it is missing; main does not change the version of an installed binary, and warns when it differs from openbao_version. With --skip-tags install on 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_LOCK and the configuration no disable_mlock; MemorySwapMax=0 keeps the server's memory out of swap and LimitCORE=0 out of core dumps. The unit stops the server with SIGINT, runs with an empty capability set and ProtectSystem=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: --check is the supported preview; a play-level check_mode: true is not supported. Under --check on 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).