From 9a6d8d680b554cbfcceda581aeaaede2f2287654 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Wed, 25 Jan 2023 01:45:48 +0000 Subject: [PATCH] Update file run_onchange_after_11-symlink-ansible-roles.tmpl --- ...change_after_11-symlink-ansible-roles.tmpl | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 1d3c31ca..3bd8c00d 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 @@ -27,6 +27,27 @@ find "$HOME/.local/src/gas-station/roles" -mindepth 2 -maxdepth 2 -type d | whil done if [ -f "$HOME/.local/src/gas-station/requirements.yml" ]; then + ### Install Ansible Galaxy and dependencies if missing + if ! command -v ansible-galaxy > /dev/null; then + if ! command -v pipx > /dev/null; then + logg info 'Installing pipx via Homebrew' + brew install pipx + logg info 'Running `pipx ensurepath`' + pipx ensurepath + fi + logg info 'Installing `ansible-core` via pipx' + pipx install ansible-core + if [ -d /Applications ] && [ -d /System ]; then + logg info 'Injecting macOS-specific pipx dependencies via pipx' + pipx inject ansible-core PyObjC PyObjC-core + fi + logg info 'Injecting Ansible dependencies via pipx' + pipx inject ansible-core docker lxml netaddr pexpect python-vagrant pywinrm requests-credssp watchdog + mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/megabyte-labs" + touch "${XDG_CACHE_HOME:-$HOME/.cache}/megabyte-labs/ansible-installed" + fi + + ### Ensure Ansible Galaxy was successfully loaded and then install the Ansible Galaxy requirements if command -v ansible-galaxy > /dev/null; then logg info 'Ensuring Ansible Galaxy collections are installed' export ANSIBLE_CONFIG="${XDG_DATA_DIR:-$HOME/.local/share}/ansible/ansible.cfg"