Skip to content

Instantly share code, notes, and snippets.

@TheFrozenFire
Created November 15, 2017 18:21
Show Gist options
  • Save TheFrozenFire/2f0ebd7b3c08f259ed015661af06da3d to your computer and use it in GitHub Desktop.
Save TheFrozenFire/2f0ebd7b3c08f259ed015661af06da3d to your computer and use it in GitHub Desktop.
Ansible from virtualenv
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -d ${DIR}/ansible-install/ENV ]; then ( ${DIR}/ansible-install/setup.sh ); fi
if [ -z ${ANSIBLE_CONFIG+x} ]; then export ANSIBLE_CONFIG="${DIR}/ansible-install/ansible.cfg"; fi
if [ -z ${ANSIBLE_NO_GCLOUD+x} ]; then ${DIR}/ansible-install/setup-gcloud.sh; fi
source ${DIR}/ansible-install/ENV/bin/activate
(cd ${DIR} && exec ansible "$@")
EXIT_CODE=$?
deactivate
exit ${EXIT_CODE}
-r requirements.txt
ansible-lint == 3.4.12
ansible == 2.3.0
ansible-vault >= 1.0.5, < 1.1
apache-libcloud >= 0.13
backports.ssl-match-hostname; python_version < '3.2'
setuptools >= 34.0
jq >= 0.1.6
kazoo >= 2.1
dnspython
boto
boto3
botocore
#!/usr/bin/env bash
if [ "$(gcloud auth list --format=json)" == "[]" ]; then
echo "No gcloud authorization detected. Initializing gcloud."
echo "Set ANSIBLE_NO_GCLOUD=true to disable this behaviour."
echo
gcloud init
fi
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
virtualenv --prompt="CallFire Ansible" "${DIR}/ENV"
source ${DIR}/ENV/bin/activate
pip install --upgrade pip
pip install -r ${DIR}/requirements${SETUP_ENVIRONMENT:+"-${SETUP_ENVIRONMENT}"}.txt
deactivate
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -d ${DIR}/ansible-install/ENV ]; then ( ${DIR}/ansible-install/setup.sh ); fi
if [ -z ${ANSIBLE_CONFIG+x} ]; then export ANSIBLE_CONFIG="${DIR}/ansible-install/ansible.cfg"; fi
if [ -z ${ANSIBLE_NO_GCLOUD+x} ]; then ${DIR}/ansible-install/setup-gcloud.sh; fi
source ${DIR}/ansible-install/ENV/bin/activate
(cd ${DIR} && exec ansible-playbook "$@")
EXIT_CODE=$?
deactivate
exit ${EXIT_CODE}
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -d ${DIR}/ansible-install/ENV ]; then ( ${DIR}/ansible-install/setup.sh ); fi
if [ -z ${ANSIBLE_CONFIG+x} ]; then export ANSIBLE_CONFIG="${DIR}/ansible-install/ansible.cfg"; fi
source ${DIR}/ansible-install/ENV/bin/activate
(cd ${DIR} && exec ansible-vault "$@")
EXIT_CODE=$?
deactivate
exit ${EXIT_CODE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment