-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipx_ansible
executable file
·34 lines (29 loc) · 1.16 KB
/
pipx_ansible
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Handle pipx venvs for Ansible toolchain
ACTIVE=$1
INJECT="ara ansible-merge-vars dnspython jmespath netaddr passlib proxmoxer python-dateutil pytz requests[socks] setuptools"
TOOLS="ansible-builder ansible-creator ansible-lint ansible-navigator ansible-runner ansible-sign ara molecule pre-commit"
echo "Updating toolchain via PipX"
for i in $TOOLS
do
pipx install $i 1>/dev/null 2>&1 || pipx upgrade $i 1>/dev/null 2>&1
pipx inject $i setuptools 1>/dev/null 2>&1
done
echo "Processing PipX environment for Ansible $ACTIVE"
env=${ACTIVE/./-}
if ! test -d $HOME/.local/share/pipx/venvs/ansible-core-$env
then
pipx install ansible-core==$ACTIVE --suffix _$env 1>/dev/null 2>&1
fi
pipx inject ansible-core_$env $INJECT 1>/dev/null 2>&1
pipx upgrade ansible-core_$env --include-injected --pip-args "ansible-core<=${ACTIVE}.99" 1>/dev/null 2>&1
if test -n "$ACTIVE"
then
env=${ACTIVE/./-}
echo "Activating venv for Ansible $ACTIVE"
cd $HOME/.local/bin
for i in ansible ansible-config ansible-connection ansible-console ansible-doc ansible-galaxy ansible-inventory ansible-playbook ansible-pull ansible-test ansible-vault
do
ln -nfs ${i}_${env} $i
done
fi