eskp.net


Package ansible-playbook command into a PEX file

PEX files are self-contained executable Python virtual environments. Used here to package ansible-playbook command into a single executable with no outside dependencies. This helps us with deploying Ansible onto build servers running in a secure or offline environments where Ansible installation with a package manager is not an option.

From a host that has Ansible installed:

yum install python-devel
easy_install pip
pip install virtualenv
virtualenv pex
source pex/bin/activate
pip install pex
pex pex requests -c pex -o ~/bin/pex
export PATH=$PATH:~/bin
pex ansible -c ansible-playbook -o ansible-playbook.pex
./ansible-playbook.pex --version