Update 2 files

- /home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl
- /home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl
This commit is contained in:
Brian Zalewski 2023-01-25 01:22:20 +00:00
parent 7bfe2ddbf1
commit 46c96c8141
2 changed files with 15 additions and 14 deletions

View file

@ -16,11 +16,12 @@ if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then
find "$HOME/.local/share/chezmoi" -type f -name "encrypted_*" | while read ENCRYPTED_FILE; do
logg info "Removing $ENCRYPTED_FILE"
rm -f "$ENCRYPTED_FILE"
FALLBACK_FILENAME="$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_/encrypted-fallback_/')"
if [ -f "$FALLBACK_FILENAME" ]; then
logg info 'Substituting encrypted-file fallback for `'"$ENCRYPTED_FILE"'`'
mv -f "$FALLBACK_FILENAME" "$(echo "$ENCRYPTED_FILE" | sed 's/encrypted_//')"
fi
done
else
logg info 'Removing files used when an encryption key is not configured'
find "$HOME/.local/share/chezmoi" -type f -name "encrypted-fallback_*" | while read UNENCRYPTED_FILE; do
logg info "Removing $UNENCRYPTED_FILE"
rm -f "$UNENCRYPTED_FILE"
done
fi
fi

View file

@ -11,26 +11,26 @@
{{- end }}
logg info 'Ensuring Gas Station roles are symlinked to ~/.local/share/ansible/roles'
mkdir -p "$XDG_DATA_HOME/ansible/roles"
mkdir -p "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles"
find "$HOME/.local/src/gas-station/roles" -mindepth 2 -maxdepth 2 -type d | while read ROLE_PATH; do
ROLE_FOLDER="professormanhattan.$(echo "$ROLE_PATH" | sed 's/.*\/\([^\/]*\)$/\1/')"
ALT_ROLE_FOLDER="$(echo "$ROLE_PATH" | sed 's/.*\/\([^\/]*\)$/\1/')"
if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER")" != "$ROLE_PATH" ]; then
if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER" ] || [ "$(readlink -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER")" != "$ROLE_PATH" ]; then
logg info 'Symlinking `'"$ROLE_FOLDER"'`'
rm -f "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER"
ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ROLE_FOLDER"
rm -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER"
ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ROLE_FOLDER"
fi
if [ ! -d "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER" ] || [ "$(readlink -f "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER")" != "$ROLE_PATH" ]; then
rm -f "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER"
ln -s "$ROLE_PATH" "$XDG_DATA_HOME/ansible/roles/$ALT_ROLE_FOLDER"
if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER" ] || [ "$(readlink -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER")" != "$ROLE_PATH" ]; then
rm -f "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER"
ln -s "$ROLE_PATH" "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/roles/$ALT_ROLE_FOLDER"
fi
done
if [ -f "$HOME/.local/src/gas-station/requirements.yml" ]; then
if command -v ansible-galaxy > /dev/null; then
logg info 'Ensuring Ansible Galaxy collections are installed'
export ANSIBLE_CONFIG="$HOME/.local/share/ansible/ansible.cfg"
ansible-galaxy install -r "$HOME/.local/share/ansible/requirements.yml" || EXIT_CODE=$?
export ANSIBLE_CONFIG="${XDG_DATA_DIR:-$HOME/.local/share}/ansible/ansible.cfg"
ansible-galaxy install -r "${XDG_DATA_DIR:-$HOME/.local/share}/ansible/requirements.yml" || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
logg error 'Failed to install Ansible requirements from Ansible Galaxy'
if [ -d "$HOME/.local/src/gas-station/collections" ]; then