- Python 76.5%
- Jinja 23%
- Shell 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVUe4g65L7UnUVqHmQp7kG |
||
| .forgejo/workflows | ||
| changelogs | ||
| extensions/molecule | ||
| meta | ||
| plugins | ||
| roles | ||
| tests/unit | ||
| .ansible-lint | ||
| .copier-answers.yml | ||
| .gitignore | ||
| .gitleaks.toml | ||
| .pre-commit-config.yaml | ||
| .yamllint | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| galaxy.yml | ||
| LICENSE | ||
| README.md | ||
| ruff.toml | ||
| SECURITY.md | ||
belowtoxic.openbao
OpenBao as the source of truth for the belowtoxic infrastructure code:
- configuration as code for OpenBao itself - KV mounts, auth methods, SSH certificate authorities, ACL policies, AppRoles;
- an inventory plugin that turns non-secret intent documents stored in OpenBao (hosts, guests, global settings) into Ansible inventory;
- a small, idempotent API module used by both.
Works with OpenBao and HashiCorp Vault (same API). No Python dependencies beyond ansible-core.
Part of belowtoxic-ansible.
Content
| Name | Type | Purpose |
|---|---|---|
belowtoxic.openbao.openbao_server |
role | OpenBao in a container: raft on a volume, VPN-only listeners, ACME DNS-01 certificate, encrypted snapshots (README) |
belowtoxic.openbao.openbao_config |
role | Mounts, auth, SSH CAs, policies, AppRoles |
belowtoxic.openbao.infra |
inventory | Hosts and guests from infra/hosts/*, infra/guests/*, infra/global |
belowtoxic.openbao.bao_api |
module | Read-compare-write any OpenBao API resource (check and diff mode) |
Reading secrets at use time is left to
community.hashi_vault
(vault_kv2_get with no_log: true).
Data layout
infra/ KV v2, non-secret intent (inventory plugin reads it)
global domain, admin CIDRs, ...
hosts/<host> role, storage, NAT network, IPv6 delivery mode, ...
guests/<guest> type (vm|microvm), host, os, sizing, nics[], expose[]
secrets/ KV v2, secrets - read at use time, never inventory
ssh-host/ SSH engine: signs host keys (role "hosts")
ssh-client/ SSH engine: short-lived user certificates (role "ansible")
auth/approle/ AppRoles "ansible-ci" (automation), "openbao-snapshot" (snapshot timer)
Policies created by the role:
| Policy | For | Grants |
|---|---|---|
ansible-ci |
CI and automation (AppRole) | read infra/, read secrets/, sign SSH user and host certificates, wrap tokens |
infra-editor |
humans editing intent | create/update infra/ |
ansible-admin |
interactive runs of openbao_config |
everything the role manages - no seal, audit or raw access |
openbao-snapshot |
the snapshot timer of openbao_server (AppRole, 127.0.0.1 only) |
read sys/storage/raft/snapshot |
Quickstart
Configure OpenBao (admin token, interactively):
# playbooks/openbao_config.yml
- name: OpenBao configuration
hosts: localhost
connection: local
gather_facts: false
vars:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
roles:
- role: belowtoxic.openbao.openbao_config
export VAULT_ADDR=https://bao.example.com:8200
bao login -method=oidc # or userpass; the token lands in ~/.vault-token
ansible-playbook -i localhost, playbooks/openbao_config.yml --diff --check
-i localhost, keeps a site inventory that reads OpenBao (which is not set
up yet) out of the first run. It also makes localhost an ordinary host whose
Python Ansible would probe on PATH (a pyenv shim, a system Python);
ansible_python_interpreter keeps the modules on Ansible's own Python. Host certificate domains, delegated tokens for
VMs and agents: see the role README.
The role never creates AppRole secret IDs and never rotates CA keys. Issue a secret ID for CI explicitly and store it as a Forgejo secret:
bao read -field=role_id auth/approle/role/ansible-ci/role-id
bao write -f -field=secret_id auth/approle/role/ansible-ci/secret-id
Inventory source (file name must end in infra.yml or openbao.yml):
# inventory/20-infra.yml
plugin: belowtoxic.openbao.infra
keyed_groups:
- key: infra_host.role | default(omit)
prefix: role
The plugin authenticates with BAO_TOKEN/VAULT_TOKEN, else AppRole
(BAO_ROLE_ID + BAO_SECRET_ID), else the token helper files
~/.bao-token/~/.vault-token. It creates the groups infra_hosts,
infra_guests, infra_guests_<type> and infra_guests_on_<host>, and the
variables infra_host, infra_guest and infra_global. Values are marked
unsafe, so data from OpenBao is never evaluated as a template.
Security notes
- Secrets never enter the inventory; keep them under
secrets/. bao_apimarkstokenasno_log; useno_log: trueon tasks whosedatacontains secrets and list such keys inignore_keys.- Use
validate_certs: true(default) andca_certfor a private CA.
Development
eval "$(../toolchain/bin/bt-ci-setup)"
bt-ci lint && bt-ci sanity && bt-ci units
bt-ci molecule config # starts a throwaway `bao server -dev` on 127.0.0.1
License
GPL-3.0-or-later, see LICENSE.