I am building an Ansible server using Ubuntu Server 20.04 64bit and Ansible 2.8.13. Among other things ansible will manage some mysql and postgres servers among other things. In the near future there might be a version upgrade of ansible as well. So based on my limited knowledge this is what I have so far
# Install
sudo apt-get -yqq install python3-pip python3-venv mysql-client postgresql-client libpq-dev
sudo python3 -m venv --clear /opt/ansible
. /opt/ansible/bin/activate
pip3 install wheel setuptools
pip3 install PyMySQL psycopg2 ansible==2.8.13
deactivate
Given that in order to run those executable one has to write wrapper scripts for each ansible executable to pass over into main session.
/usr/local/bin/ansible-playbook.2.8.sh
#!/usr/bin/env sh
. /opt/ansible/bin/activate
/opt/ansible/bin/ansible-playbook "$@"
result=$?
deactivate
exit "${result}"
And finally map the main executable with update-alternatives
update-alternatives --install /usr/local/bin/ansible-playbook ansible-playbook
"/usr/local/bin/ansible-playbook-2.8.sh" 1
Is this considered decent approach in 2021 or is there something better?
Thanks,
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…