Last active
November 8, 2022 22:21
-
-
Save dginhoux/a84b8457a4cef762119fcc22f408a48e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export ANSIBLE_DIR="/mnt/gfs_lv_ansible" | |
export VENV_NAME="venv" | |
export VENV_DIR="$ANSIBLE_DIR/$VENV_NAME" | |
export PIP_LIST="ansible ansible-lint jinja2 jmespath yamllint" | |
export ACTION=$1 | |
if [ "$ACTION" != 'install' ] && [ "$ACTION" != 'uninstall' ]; then | |
echo set action install or uninstall | |
exit 1 | |
fi | |
if [ ! -f $VENV_DIR/bin/activate ]; then | |
python3 -m virtualenv --always-copy --clear $VENV_DIR | |
fi | |
if [ -f $VENV_DIR/bin/activate ]; then | |
source $VENV_DIR/bin/activate | |
if [ $? -eq 0 ] && [ $VIRTUAL_ENV == $VENV_DIR ]; then | |
python3 -m pip $ACTION --no-input --disable-pip-version-check --no-cache-dir $PIP_LIST | |
if [ "$ACTION" == 'install' ]; then | |
python3 -m pip freeze --local > $ANSIBLE_DIR/requirement_$VENV_NAME.txt | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment