From 2b258105e80eae3df2896f1694b8b718abd53e48 Mon Sep 17 00:00:00 2001 From: Tobias Petrich Date: Sat, 27 Dec 2025 17:46:43 +0100 Subject: [PATCH] make more idempotent and extend README.md --- ansible/README.md | 46 ++++++++++++++++++- ansible/roles/hardening/tasks/ssh.yml | 1 + .../rootless_host/tasks/rootless_ports.yml | 1 + .../roles/services/tasks/enable_linger.yml | 12 ++++- .../roles/services/tasks/enable_service.yml | 4 +- ansible/roles/services/tasks/main.yml | 5 +- ansible/roles/services/tasks/setup.yml | 5 ++ ansible/roles/services/vars/main.yml | 10 ++-- 8 files changed, 74 insertions(+), 10 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index 53949b8..77d95e6 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -8,6 +8,8 @@ they are handled as specific for how each user accesses a specific host. (Vaulted) Variables for the services are stored in the group_vars, they are shared between all administrators of the host. +Vaults can be automatically decrypted using a GPG key (best using a connected Yubikey). + ## Requirements Create vars and vault file for accessing the host following this structure. @@ -27,8 +29,50 @@ ansible_become_method: sudo ansible_become_pass: EXAMPLE ``` +## Automatic vault decryption setup + +Vaults can have a Vault ID, which is specified in the vault file. Just change the starting line in the file +`$ANSIBLE_VAULT;1.2;AES256` to `$ANSIBLE_VAULT;1.2;AES256;podman_hosts`. + +Assumption: The GPG key ID intended for use is D5AF83DDD5F8523A. + +Create an encrypted GPG file called `vault-passwords.gpg` for the GPG key you will be using with content like this: +```text +VAULT_ID1 vault_password1 +VAULT_ID2 vault_password2 +``` + +This can be created ad-hoc using either fish or bash. +Fish supports a command called `psub` which can be used to pipe the output of a command into a file securely. +Bash can be used with a cat heredoc. + +### fish +```fish +gpg --quiet --encrypt --recipient D5AF83DDD5F8523A --output vault-passwords.gpg (psub) +``` +Then in the psub editor, enter the content: +```text +VAULT_ID1 vault_password1 +VAULT_ID2 vault_password2 +``` + + +### bash +```bash +gpg --quiet --encrypt --recipient D5AF83DDD5F8523A --output vault-passwords.gpg <