Last active
May 31, 2023 17:43
-
-
Save alces/075c871cc4ba76df80740107f677e694 to your computer and use it in GitHub Desktop.
Make portable Ansible distribution which can be installed on another host with the same Python version simply by un-tarring it in the same directory. Virtualenv is used during build stage, but isn't required on the target machine. Originally, written as Vagrant provision script but probably can be used outside Vagrant.
This file contains 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 | |
ANSIBLE_ROOT=${ANSIBLE_ROOT:-/opt/ansible} | |
DISTR_ROOT=${DISTR_ROOT:-/vagrant} | |
yum install -y python-setuptools python-devel libffi-devel openssl-devel | |
easy_install virtualenv | |
virtualenv "$ANSIBLE_ROOT" | |
. "$ANSIBLE_ROOT/bin/activate" | |
# PY_LIBS can contain a space-separated list of Python libraries your playbooks require to run (e.g., "dnspython shade") | |
pip install $PY_LIBS ansible | |
deactivate | |
echo "Ansible is installed as $ANSIBLE_ROOT/bin/ansible" | |
cd "$ANSIBLE_ROOT/.." && tar czf "$DISTR_ROOT/ansible.tgz" $(basename "$ANSIBLE_ROOT") | |
echo "Ansible distribution is saved as $DISTR_ROOT/ansible.tgz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment