Vault
Vault deployment, secrets management, and certificate issuance
Architecture
This diagram describes the maintained architecture source, not live inventory or service health.
The Mermaid source is authoritative; Bazel renders its light and dark SVGs.


Links
Deployment
bazel run //infra/vault/tf_setup:tf.apply # Create VMs (requires an active Vault host)
bazel run //infra/vault/ansible # Set up hosts (BM and VMs)
bazel run //infra/vault/tf:tf.apply # Configure vault
The Molecule SSH issuer has a separate Terraform
stage and state.
Backup
bazel run //infra/vault:backup
Unseal
With a working Vault:
bazel run //infra/vault:unseal
Without a working Vault:
bazel run //infra/vault:unseal_standalone
Fix quorum
bazel run //infra/vault/ansible:fix_quorum
Set up only VMs
bazel run //infra/vault/ansible:ansible.vm # Set up only VMs
bazel run //infra/vault/ansible:ansible.bm # Set up only bare metal
Tf
Plan:
bazel run //infra/vault/tf:tf.plan
Apply:
bazel run //infra/vault/tf:tf.apply
Run terraform directly:
bazel run //infra/vault/tf:tf.direct -- -chdir="${PWD}" plan
Replace VMs
bazel run //infra/vault/tf:tf.apply -- -replace 'module.vm_ha["host2"].proxmox_vm_qemu.vm' -replace 'module.vm_ha["host3"].proxmox_vm_qemu.vm
Generate and import a user cilent certificate
username="username"
bazel run //infra/vault:gen_client_cert -- --user "${username}" --output_dir "${PWD}"
bazel run //tools/ykman -- piv certificates import 9A "${PWD}/${username}.pfx"
bazel run //tools/ykman -- piv keys import 9A "${PWD}/${username}.pfx"
Generate a host cilent certificate
bazel run //infra/vault:gen_client_cert -- --host some-host --output_dir "${HOME}/.al/client_cert"
Generate a user device cilent certificate
bazel run //infra/vault:gen_client_cert -- --host some-host --user username --output_dir "${HOME}/.al/client_cert"
Unseal
- Prepare encrypted unseal token
- Run and input the encrypted token:
bazel run //infra/vault:unseal
Root token
- Prepare encrypted unseal token
- Run and input the encrypted token:
bazel run //infra/vault:gen_root_token -- --pgp_key path_to_public_gpg_key_in_base64
Generate an EAB for ACME
bazel run //infra/vault -- write -f pki/ica_servers/roles/ica_servers_dc1_pve1/acme/new-eab
Sign a client ssh key
bazel run //:vault -- write ssh/clients/sign/admins ttl=30000000 public_key=@"${HOME}/.ssh/key"
Revoke all tokens
bazel run //infra/vault -- token revoke -mode=path auth
Vault certificates
Renew the Vault server certificate through its Ansible role. The vault_tls
tag issues a certificate, installs its chain and private key, and reloads Vault
with SIGHUP. It stops on certificate errors and does not run the host setup,
package installation, or service restart tasks.
Run from the repository root. Keep SSH host verification enabled by deriving a
temporary known_hosts entry from the repository-owned public SSH CA:
vault_recovery_dir="${PWD}/out/vault-certificate-recovery"
mkdir -p "${vault_recovery_dir}"
printf '@cert-authority host1.vault.alwaldend.com,host1.vault.dc1.alwaldend.com %s\n' \
"$(cat data/ssh/ca_servers.pub)" \
>"${vault_recovery_dir}/ssh_known_hosts"
For an expired server certificate, temporarily disable Vault certificate
verification for this recovery command only. The SSH options trust that CA
only for this invocation and retain the existing SSH certificate’s host alias:
env VAULT_SKIP_VERIFY=true \
ANSIBLE_SSH_COMMON_ARGS="-o StrictHostKeyChecking=yes \
-o HostKeyAlias=host1.vault.alwaldend.com \
-o UserKnownHostsFile=\"${vault_recovery_dir}/ssh_known_hosts\"" \
bazel run //infra/vault/ansible:ansible -- \
--limit host1.vault.alwaldend.com --tags vault_tls
Vault must be reachable and unsealed, and the host token must allow the
component’s AppRole login. If that token has expired, connect the login YubiKey
and refresh it first:
bazel run //tools/vault/login -- simeonwarren --insecure
This login replaces the host token. Stop if it fails; a missing YubiKey cannot
be fixed by disabling TLS verification. Neither command changes the persistent
TLS verification configuration. Do not add the bypass to shell profiles,
BUILD.bazel, or Ansible defaults, and do not use verbose or diff output for the
certificate tasks. The temporary public known_hosts projection does not
modify the host’s SSH configuration; do not replace it with an unverified
ssh-keyscan result or disable SSH host verification.
After renewal, verify Vault with certificate validation enabled:
env -u VAULT_SKIP_VERIFY bazel run //:vault.status
For renewal before expiry, omit VAULT_SKIP_VERIFY=true from the Ansible
command. The current inventory serves Vault from host1; review the inventory
before changing the host limit. Its inventory name remains
host1.vault.alwaldend.com to preserve the Vault node identity; ansible_host
connects through the DNS-owned name host1.vault.dc1.alwaldend.com. Certificate
alternate names include this connection hostname for the existing unseal
endpoint, as well as the shared Vault service names.
Read OIDC client info
bazel run //infra/vault -- read identity/oidc/client/src_infra_dc1_forgejo1_provider
Read all entity aliases
bazel run //infra/vault -- list -format json identity/entity-alias/id | jq ".[]" | xargs "-I{}" bazel run //infra/vault -- read "identity/entity-alias/id/{}"
Independent AppRole projects
The NAS,
development,
AL, and
download identities use independent
Terraform roots and states. The core root retains shared mounts and global
memberships, discovering those projects’ existing identities by name.
2 - Molecule SSH issuer
Standalone Terraform stage for the Molecule SSH certificate authority
This Terraform root owns the ssh/molecule mount, Ed25519 issuer, and test
AppRole. It uses one state and a single set of deployment targets under
//infra/vault/ssh_molecule.
The smoke role signs Ed25519 keys for the fedora user principal. Its
default certificate lifetime is 15 minutes, and callers can request up to
one hour. The ssh_molecule_sign_smoke policy permits signing through this
role. The test AppRole assigns that policy to src_tools_molecule
and grants global_admins access to bootstrap it.
The former AppRole backend was retired after the state transfer.
After deployment, the seed ISO can use the CA public key from
ssh/molecule/public_key as its build input. The test generates its own keypair
and sends the public key to ssh/molecule/sign/smoke at runtime.
Offline validation uses //infra/vault/ssh_molecule:tf_tests.validate_test.
The stage has its own :tf.plan and :tf.apply targets.
3 - OpenSpec
3.1 - Specifications
3.1.1 - Download identity
3.1.1.1 - download-identity Specification
Purpose
Provide a dedicated Vault identity for download infrastructure while keeping
state, credential references, and provider permissions scoped to its needs.
Requirements
Requirement: Dedicated component authentication
Vault configuration SHALL declare src_infra_download using the existing
AppRole backend and reusable identity modules. Its state permissions SHALL
cover the component’s own environment and DNS state keys, not another
component’s state namespace.
Scenario: Inspect component state access
- WHEN the download identity’s effective state policy is evaluated
- THEN it grants access to download-owned state and locks
- AND it does not grant access to unrelated component state
Requirement: Required provider and SSH assignments
The identity SHALL expose the membership and identity outputs needed for
Yandex folder provisioning and XCP-ng resource-set assignment. It SHALL
receive the required component SSH permissions and DNS provider-secret reads
for global and local records without administrative provider credentials.
Scenario: Prepare both environment assignments
- WHEN provider owners consume the declared download identity
- THEN they can assign its Yandex folder and XCP-ng resource set
- AND no unrelated component’s identity is reused for deployment
Requirement: Secret references and certificate automation
Checked-in declarations SHALL contain secret references only. Download
certificate automation SHALL receive role-scoped EAB access for internal Vault
HTTP-01 certificates. The role SHALL permit only alwaldend.com,
download.alwaldend.com, and www.alwaldend.com, without subdomain or client
certificate permissions. Public Let’s Encrypt HTTP-01 SHALL require no DNS
challenge credential. Adding this
identity SHALL NOT broaden unrelated identities’ policies.
Scenario: Review the source change
- WHEN the role and its policy declarations are inspected
- THEN they name Vault paths and permissions without embedding credential values
- AND unrelated identity permissions remain unchanged
Requirement: Independent identity state
The download identity SHALL be deployed from its own Terraform root and
backend under infra/vault/approles/src_infra_download. Shared identity IDs
SHALL be resolved by name through data sources rather than parent-module
inputs or another root’s state. Shared group membership lists SHALL retain
one owner in the core Vault stage.
Scenario: Bootstrap without the download identity
- WHEN shared Vault mounts and the administrative/operator identities already exist
- THEN the standalone root can create the download identity using administrative authentication
- AND a subsequent core Vault apply resolves the new identity/group by name and adds their memberships
3.1.2 - Infra vault
3.1.2.1 - Infrastructure Vault
Purpose
Describe the Vault host configuration, authentication and certificate services,
and packaged recovery entry points. This baseline concerns checked-in desired
state and supported wrapper structure; it does not establish live unsealed
state, successful backups, quorum, or certificate freshness.
Baseline source revision: 550d7e79b1f5fdbc2b6017b75178471d6914082f.
Observation date: 2026-09-08. Sources are linked in full; no excerpts are used.
Sources: operator documentation,
operational wrappers,
Ansible entry points,
Vault host template,
authentication backends,
storage engines,
server PKI,
client PKI, and
public CA outputs.
Requirements
Requirement: Separate host provisioning from Vault configuration
The documented workflow SHALL separate tf_setup VM provisioning, Ansible host
setup, and the tf Vault configuration stage. Ansible SHALL expose combined,
VM-only, and bare-metal-only setup entry points using the shared host and Vault
roles.
Scenario: Prepare an authorized host setup
- WHEN an operator selects
ansible.vm or ansible.bm - THEN the wrapper selects the matching checked-in playbook and inventory
- AND Vault’s API configuration remains owned by the separate Terraform stage
The host template SHALL configure TLS API and cluster endpoints on ports 8200
and 8201 and Raft storage under /opt/vault/raft. It SHALL derive each Raft node
identifier from the inventory hostname and emit retry-join addresses for hosts
in the Vault inventory group.
Scenario: Render a Vault host configuration
- WHEN Ansible renders
vault.hcl for a member of the Vault group - THEN its API and cluster URLs use its inventory hostname
- AND Raft receives that hostname as node ID and the group’s HTTPS join URLs
Requirement: Declare authentication and secret-engine boundaries
Terraform SHALL declare userpass, approle, and cert authentication
backends, a version-two KV engine at secrets, and a transit engine at
transit/default. Client and server certificate authorities SHALL remain
distinct, and server PKI ACME SHALL require external account binding with the
default directory policy set to forbid.
- WHEN the main Terraform configuration is evaluated
- THEN authentication, KV, transit, client PKI, and server PKI are distinct
declared resources
- AND server ACME is enabled with
eab_policy = "always-required" - AND published CA output files contain certificate or public-key material
Requirement: Package recovery and certificate operations explicitly
The package SHALL expose separate wrappers for backup, ordinary unseal,
standalone unseal, client certificate generation, and root-token generation.
Standalone unseal SHALL use the default_no_auth environment without selecting
the ordinary unseal plugin; these wrappers SHALL NOT imply that recovery has
been executed successfully.
Scenario: Select the standalone unseal workflow
- WHEN an authorized operator invokes
//infra/vault:unseal_standalone - THEN the wrapper selects the packaged unseal utility and declared Vault
endpoint with its no-auth environment
- AND success remains an operational result to be observed separately
Requirement: Give each DNS owner a component identity
Every owner that manages DNS records through Terraform SHALL use its existing
component AppRole or a dedicated owner AppRole when one is missing. A DNS-only
identity SHALL retain the shared AppRole module’s own-state and named shared
secret access without cloud provisioning, SSH, or PKI permissions. Existing
component identities and unrelated authentication flows SHALL remain stable.
Scenario: Introduce a landing site’s DNS stage
- WHEN a project has DNS records but no existing component AppRole
- THEN Vault configuration declares an AppRole named for that owner
- AND the identity can manage its own Terraform state without access to
another owner’s state
Scenario: Add host DNS management
- WHEN host_bot uses its dedicated DNS AppRole
- THEN its existing Ansible authentication remains unchanged
Requirement: Restrict provider secret reads to owned DNS views
DNS identities SHALL receive read access to the existing Cloudflare credential
only when they own global records and to the existing RouterOS DNS credential
only when they own dc1 records. DNS access SHALL NOT grant writes to either
provider secret or duplicate credential values.
- WHEN an owner declares only global records
- THEN its DNS policy grants Cloudflare credential reads
- AND its DNS policy grants no RouterOS credential access
- WHEN an owner declares global and dc1 records
- THEN its DNS policy grants reads for both existing credential references
- AND neither read policy grants mutation of the provider credential
Requirement: Recover an expired server certificate with scoped Ansible tasks
The packaged Vault Ansible workflow SHALL expose a vault_tls tag that issues
and installs the configured server certificate and private key, then reloads
Vault. Selecting only this tag SHALL NOT update packages, the service binary,
host configuration, or Raft peers. Certificate material SHALL be suppressed
from task output. Explicit certificate renewal SHALL stop on issuance or
installation failure before reloading the service.
Scenario: Renew one authorized host’s certificate
- WHEN the operator selects
vault_tls and limits the play to one Vault host - THEN only certificate issuance, certificate and key installation, and
service reload are selected, in addition to read-only fact gathering
- AND a failed certificate task prevents the reload
Requirement: Scope certificate-verification bypass to recovery invocations
The recovery procedure SHALL use an invocation-scoped verification override
only when an expired server certificate prevents the authorized renewal. It
SHALL retain the existing Vault authentication and injection flow, require a
valid bootstrap login, and verify the recovered service with certificate
validation restored. The procedure SHALL NOT persist insecure TLS defaults.
Scenario: Certificate expiry prevents authenticated renewal
- WHEN an authorized operator performs the documented recovery
- THEN the temporary override applies to credential injection and certificate
issuance within that command
- AND a failed bootstrap login prevents proceeding to renewal
- AND success is established separately with normal TLS verification
3.1.3 - X article uploader identity
3.1.3.1 - X Article uploader identity
Purpose
Describe the uploader’s dedicated Vault identity, component-scoped credential
access, and injected OAuth references. These declarations do not establish that
a live identity or credential has been provisioned.
Requirements
Requirement: Dedicated component identity
Vault configuration SHALL declare a src_projects_x_article_uploader identity
through the existing AppRole backend and reusable identity module, so the
uploader authenticates as itself rather than sharing another component’s role.
Checked-in declarations SHALL contain secret references only.
Scenario: Inspect component authentication
- WHEN the uploader’s identity is evaluated
- THEN it authenticates through the shared AppRole backend as
src_projects_x_article_uploader - AND it does not reuse another component’s role or entity
Requirement: Least-privilege access to the publication credential
The identity’s policy SHALL grant access to the uploader’s own credential path
and SHALL NOT grant access to another component’s secrets. The credential value
SHALL live in Vault under the identity’s own AppRole subtree, read through the
shared module’s own-subtree policy, and the checked-in source SHALL reference it
by mount and path only.
Scenario: Reference the credential by path
- WHEN the credential mount and its logical path are evaluated for the
injected reference
- THEN the checked-in source names the mount and the path and no credential
value, so no secret enters source
- AND the path lies inside the identity’s own AppRole subtree, so the shared
module’s own-subtree policy grants the read
Scenario: Read the publication credential
- WHEN the uploader reads its X API credential through the injection flow
- THEN the read succeeds against the uploader’s own path
- AND the credential value is not present in checked-in source
Scenario: Attempt to read another component’s secret
- WHEN the uploader’s effective policy is evaluated against another
component’s credential path
- THEN the policy grants no read access to that path
Requirement: Injected credential reference
The publication credential is an OAuth 1.0a user-context credential, which
requires four fields: the API key, the API secret, the access token, and the
access token secret. The injected reference SHALL name one environment variable
per field, and this identity’s configuration SHALL declare those variables by
name. The references, not the values, are what checked-in configuration
carries; no credential value enters source.
Scenario: Inject the credential at run time
- WHEN the uploader’s injection runs
- THEN each of the four credential fields is placed in its named environment variable
- AND the reference, not the value, is what checked-in configuration names
4 - Tf
Terraform config
Selected userpass entries
userpass.tf contains the explicit user list, initially only
simeonwarrenbot. It generates a stable 72-character password for each selected
user and stores the username/password at
secrets/alwaldend.com/users/<username>/userpass before updating that login.
Users and the users group receive no storage grant. No deny rules are added.
The existing simeonwarren entity receives exact data/metadata read access to
secrets/alwaldend.com/users/simeonwarrenbot/userpass. This grants no writes,
namespace listing, or sibling reads. The infrastructure role can manage only
selected userpass entries, including provider-required metadata read/update,
without metadata deletion.
The account’s existing alias and token policy settings are preserved. Unchanged
configuration retains the generated password. Vault cannot return userpass
passwords for drift detection; out-of-band changes require managed rotation.
Sensitive state remains in the existing Vault backend. Do not export it or
enable debug logging. KV removal soft-deletes the entry and retains versions.
The deployment verification
records the authorized apply and live access checks.
Public certificate snapshots
This root manages Vault’s PKI and SSH issuers. Public snapshots are owned and
refreshed independently by data/ssl/alwaldend.com/tf
and data/ssh/tf; this root does not write them.
The removed blocks in outputs.tf retire the four former local_file
exports with destroy = false. A later authorized apply forgets those state
entries without deleting their files. No state migration or Vault operation is
performed merely by moving the checked-in snapshots.
DNS identities
Missing DNS-owner AppRoles compose the existing reusable
AppRole module with an owner-specific DNS policy in approles/<name>/.
DNS access grants read-only access to the existing
provider credentials for the owner’s views. Existing component identities
receive these policies through their existing module declarations.
DNS-only group membership adds no policies. These
identities retain their own state and named shared-secret access without
joining the general infrastructure AppRole group or receiving cloud
provisioning, SSH, or PKI permissions.
The operator bootstrap membership follows the existing component pattern.
An authorized Vault apply must create the roles and policies before their DNS
stages can authenticate; source validation does not establish deployed access.
Follow the DNS migration for the coordinated cutover and
the AppRole bootstrap procedure
when distinguishing missing deployment from insufficient operator access.
The Flux project owns its AppRoles and
related policies. Shared Vault resolves the Flux identities by name for
cross-component grants.
Vast team token delivery
The Vast infrastructure role declares access to
only src_infra_image_gen/vastai in addition to its existing namespace. The
policy grants data lifecycle operations and exact metadata read/delete access,
with no sibling or component-state access. It lets the team root deliver and
later remove the generated key using its own identity.
The image-generation role owns its own KV and
state subtree. Its operator member can bootstrap the AppRole and browse that
namespace in Vault. List-only permissions on exact metadata ancestors support
UI navigation without access to other secret values. An additional exact-path
metadata read/delete policy lets the component manage and remove all versions
of its web-login entry. Its explicit read permission retains metadata access
when this exact-path policy takes precedence over the namespace wildcard. It does not join the broad infrastructure AppRole group.
The legacy personal image-generation grant was removed through a reviewed
scoped apply on 2026-11-10. The replacement role and delivery grant were then
deployed under the user’s credential-only authorization; no rental was created.
The component receipt
records the operation. The existing personal user role and its browser access are independent
and remain unchanged.
5 - Tf setup
Terraform setup
This stage provisions Vault and reads network settings from dnsconfig.json.
Manage records through the dedicated DNS root.
Offline formatting is available through
//infra/vault/tf_setup:tf_tests.fmt_test.
6 - Vault DNS
Owner-local DNS Terraform
This root manages the records in dnsconfig.json using
//infra/vault/dns:tf.<operation>. Follow the
shared transfer procedure
before operating this root.