From 9af452c849f3c0682f5500cbe93ab2eb22083dc1 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Fri, 7 Nov 2025 15:59:40 -0500 Subject: [PATCH] feat: Updates hpa and config to mount home directory inside container. --- env/.config/hpa/config.toml | 10 ++++++---- env/.local/scripts/hpa | 16 ++++++++++++---- env/.local/scripts/hpa-pull | 2 +- env/.zshenv | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/env/.config/hpa/config.toml b/env/.config/hpa/config.toml index 6923ea2..f8080ae 100644 --- a/env/.config/hpa/config.toml +++ b/env/.config/hpa/config.toml @@ -1,3 +1,5 @@ +# This config is setup for running inside the docker container. +# # NOTE: # Configuration settings for the `hpa` command line tool. # You can delete settings that are not applicable to your use case. @@ -42,8 +44,8 @@ useVaultArgs = true # instead of the provided / default playbook. [playbook] -directory = '/playbook' -inventory = '/playbook/inventory.ini' +directory = '~/.local/share/hpa/playbook' +inventory = '~/.local/share/hpa/playbook/inventory.ini' version = 'main' # NOTE: @@ -51,7 +53,7 @@ version = 'main' # a remote git repository. [template] # The directory path on your local system to the template files. -directory = '/template' +directory = '~/.local/share/hpa/template' # The url to a git repository that contains your template files. # url = 'https://git.example.com/consult-template.git' @@ -66,7 +68,7 @@ directory = '/template' [vault] # Arguments to pass to commands that use `ansible-vault`, such as encrypting or decrypting # files. -args = [ '--vault-password-file=/run/secrets/vault-pass' ] +args = ['--vault-password-file=/run/secrets/vault-pass'] # An id to use when encrypting `ansible-vault` files. #encryptId = 'myId' diff --git a/env/.local/scripts/hpa b/env/.local/scripts/hpa index 28ed7fc..055e654 100755 --- a/env/.local/scripts/hpa +++ b/env/.local/scripts/hpa @@ -9,6 +9,17 @@ set -o pipefail # # Make sure to run 'hpa-init' first on this machine to setup # dependencies, if you have not done so already. +# +# This will mount my home directory inside the container, so +# it should somewhat mirror like commands are run on the host os. +# +# To attach to a shell inside the container run: +# `hpa bash` +# +# To run ansible vault commands inside the container run: +# `hpa ansible-vault ...` +# +# SCRIPTS=${SCRIPTS:-$HOME/.local/scripts} . "$SCRIPTS/utils/hpa/hpa.env" @@ -27,9 +38,6 @@ if [[ $HPA_AUTO_PULL == "1" ]] && [[ $diff -gt "$HPA_AUTO_PULL_INTERVAL" ]]; the fi podman run --rm --interactive --tty \ - --volume "$HPA_DATA_DIR/template":/template \ - --volume "$HPA_DATA_DIR/playbook":/playbook \ - --volume "$HPA_CONFIG_DIR":/config/hpa \ - --volume "$HPA_CONSULTS_DIR":/consults \ + --volume "$HOME":/root \ --secret "$HPA_VAULT_SECRET_KEY" \ "$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@" diff --git a/env/.local/scripts/hpa-pull b/env/.local/scripts/hpa-pull index d64a562..c23f33b 100755 --- a/env/.local/scripts/hpa-pull +++ b/env/.local/scripts/hpa-pull @@ -105,4 +105,4 @@ fi [[ $docker_flag == "1" ]] && pull-docker [[ $playbook_flag == "1" ]] && pull-playbook [[ $template_flag == "1" ]] && pull-template -echo "$(date +%s)" >>$HPA_CONFIG_DIR/.lastpull +date +%s >"$HPA_CONFIG_DIR/.lastpull" diff --git a/env/.zshenv b/env/.zshenv index a75a73f..44bf2ab 100755 --- a/env/.zshenv +++ b/env/.zshenv @@ -68,7 +68,7 @@ export VAULT_ADDR="https://vault.housh.dev" export CARGO_HOME="$XDG_DATA_HOME/cargo" # Tmux-Sessionator path. -export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$HOME/.config/personal:$HOME/dev:$HOME/dev/homelab/utils:$HOME/dev/homelab/services:$HOME/work/consults:$HOME/work" +export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$HOME/.config:$HOME/.config/personal:$HOME/dev:$HOME/dev/homelab/utils:$HOME/dev/homelab/services:$HOME/work/consults:$HOME/work" # Password-store # export PASSWORD_STORE_DIR="$XDG_DATA_HOME/gopass/stores/root"