-
-
Save rac3rx/8a5835ece753abd6800781a4cce6592d to your computer and use it in GitHub Desktop.
install_ansible.sh Debian/Ubuntu
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 | |
set -euo pipefail | |
set -x | |
virtualenv_path=/usr/local/ansible/stable | |
# Install packages needed on a base Debian system | |
apt-get update | |
</dev/null DEBIAN_FRONTEND=noninteractive \ | |
apt-get --yes install --no-install-recommends $( | |
echo "build-essential | |
krb5-user | |
libkrb5-dev | |
libyaml-dev | |
lsb-release | |
python3-dev | |
python3-netaddr | |
python3-pip | |
python3-setuptools | |
python3-wheel | |
python3-venv | |
sshpass" ) | |
mkdir -p /etc/ansible | |
mkdir -p ${virtualenv_path} | |
# Create requirements file for pip | |
echo " | |
ansible | |
ansible-cmdb | |
ansible-core | |
ansible-lint | |
bcrypt | |
cryptography | |
dnspython | |
docker | |
jmespath | |
netaddr | |
ntlm-auth | |
paramiko | |
pykerberos | |
pyOpenSSL | |
pypsrp | |
pywinrm | |
requests | |
requests-credssp | |
requests-kerberos | |
six | |
yamllint | |
" > ${virtualenv_path}/requirements.txt | |
# Create virtual environment we we install ansible into | |
if test ! -x ${virtualenv_path}/bin/pip ; then | |
/usr/bin/python3 -m venv ${virtualenv_path} | |
fi | |
# Upgrade pip | |
${virtualenv_path}/bin/pip install --upgrade pip | |
# install/upgrade ansible in the virtual environment | |
${virtualenv_path}/bin/pip install --upgrade --requirement ${virtualenv_path}/requirements.txt | |
# create some symlinks in /usr/local/bin for the commands in our venv | |
# so we can use them without activating the venv | |
while read item; | |
do | |
if test ! -x /usr/local/bin/${item} ; then | |
ln -rs ${virtualenv_path}/bin/$item /usr/local/bin/$item | |
fi | |
done <<EOF | |
ansible | |
ansible-config | |
ansible-connection | |
ansible-cmdb | |
ansible-doc | |
ansible-galaxy | |
ansible-inventory | |
ansible-lint | |
ansible-playbook | |
ansible-pull | |
ansible-test | |
ansible-vault | |
yamllint | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment