Wire ansible-vault for host become password (unattended host-prereqs)

Where the sudo password goes, codified:
- inventory: new [hypervisor] group (localhost, connection=local).
- host-prereqs.yml targets 'hypervisor'; become password from vaulted
  group_vars/hypervisor/vault.yml (ansible_become_password) — user creates it
  encrypted (safe to commit); README documents the exact commands.
- ansible.cfg vault_password_file = ~/.config/home-k3s/ansible-vault-pass
  (passphrase kept OUTSIDE the repo, never committed).
- ci/yamllint.yaml ignores **/vault.yml (vault blob isn't parseable YAML).
Nodes keep NOPASSWD sudo (group_vars/all) — vault scoped to the host only.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
jakman85andClaude Opus 4.8 committed 2026-08-16 15:04:44 -05:00
1 parent 67c9d5f0bc
commit 4e2ca88bd4
5 files changed
+52 -3

No files matched your search

@@ -0,0 +1,37 @@
# group_vars for the `hypervisor` host (the workstation)
The host-side plays (`playbooks/host-prereqs.yml`) run against the `hypervisor` group and need
**become (sudo) on the host**. Supply the password as an **ansible-vault-encrypted** var here — it is
encrypted, so it is safe to commit; the passphrase that decrypts it stays out of the repo.
## Two files (one committed-encrypted, one never committed)
1. **The vault passphrase** — a file **outside the repo**, referenced by `ansible.cfg`
(`vault_password_file = ~/.config/home-k3s/ansible-vault-pass`). Create it once:
```bash
mkdir -p ~/.config/home-k3s
install -m600 /dev/stdin ~/.config/home-k3s/ansible-vault-pass <<<'YOUR_VAULT_PASSPHRASE'
```
2. **The encrypted become password** — `vault.yml` in **this directory** (committed, encrypted):
```bash
cd infra/ansible
ansible-vault create inventory/group_vars/hypervisor/vault.yml
# file content (single line):
# ansible_become_password: "YOUR_HOST_SUDO_PASSWORD"
```
(`ansible-vault create` uses the passphrase file above automatically — no prompt.)
Then a rebuild is unattended:
```bash
cd infra/ansible && ansible-playbook playbooks/host-prereqs.yml
```
## Notes
- `vault.yml` is skipped by the yamllint gate (`ci/yamllint.yaml` ignores `**/vault.yml`) because a
vault blob is not parseable YAML.
- The k3s **nodes** use passwordless sudo (`group_vars/all.yml`), so they need no become password —
this vault is scoped to the `hypervisor` host only.
- If your host already has passwordless sudo, you can skip the vault and just run the playbook.
- This is the Ansible-bootstrap-layer secret (host credential), distinct from the platform's
in-cluster **SOPS + age** secrets (ADR-0007) — different layer, different tool.
+5
View File
@@ -15,3 +15,8 @@ k3s-dev-3 ansible_host=10.73.0.13
[k3s_servers:children]
k3s_primary
k3s_secondary
# The hypervisor/workstation host itself (target of host-prereqs.yml). Its become
# (sudo) password comes from the vaulted group_vars/hypervisor/vault.yml.
[hypervisor]
localhost ansible_connection=local