From 2040d0ede5e5fea9db6a697926603473d8af2046 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Thu, 5 Jan 2023 23:10:07 +0000 Subject: [PATCH] Update 2 files - /home/dot_local/share/ansible/symlink_requirements.yml.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl --- ...change_after_11-symlink-ansible-roles.tmpl | 28 +++++++++++-------- .../ansible/symlink_requirements.yml.tmpl | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl index dbbd45af..1be892bc 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.tmpl @@ -25,18 +25,24 @@ find "$HOME/.local/src/gas-station/roles" -mindepth 2 -maxdepth 2 -type d | whil fi done -if [ -f "$HOME/.local/src/gas-station/requirements.yml" ] && command -v ansible-galaxy > /dev/null; then - logg info 'Ensuring Ansible Galaxy collections are installed' - ansible-galaxy install -r "$HOME/.local/src/gas-station/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 - logg info 'Attempting to use locally stored Ansible requirements' - cd "$HOME/.local/src/gas-station/collections" - ansible-galaxy install -r requirements.yml || SECOND_EXIT_CODE=$? - if [ -n "$SECOND_EXIT_CODE" ]; then - logg error 'Failed to install requirements from both the cloud and the local copy' && exit 1 +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' + ansible-galaxy install -r "$HOME/.local/src/gas-station/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 + logg info 'Attempting to use locally stored Ansible requirements' + cd "$HOME/.local/src/gas-station/collections" + ansible-galaxy install -r requirements.yml || SECOND_EXIT_CODE=$? + if [ -n "$SECOND_EXIT_CODE" ]; then + logg error 'Failed to install requirements from both the cloud and the local copy' && exit 1 + fi fi fi + else + logg warn 'Unable to install the Ansible Galaxy requirements.yml since the ansible-galaxy executable is missing from the PATH' fi +else + logg warn '~/.local/src/gas-station/requirements.yml is missing' fi diff --git a/home/dot_local/share/ansible/symlink_requirements.yml.tmpl b/home/dot_local/share/ansible/symlink_requirements.yml.tmpl index 7532ad47..290b24be 100644 --- a/home/dot_local/share/ansible/symlink_requirements.yml.tmpl +++ b/home/dot_local/share/ansible/symlink_requirements.yml.tmpl @@ -1,3 +1,3 @@ {{- if true -}} -{{ .host.home }}/.local/src/gas-station/playbooks +{{ .host.home }}/.local/src/gas-station/requirements.yml {{- end -}}