简体   繁体   English

这是在 Ubuntu 20.04 上分发 Ansible 的正确方法吗?

[英]Is this the correct way of distributing Ansible on Ubuntu 20.04?

I am building an Ansible server using Ubuntu Server 20.04 64bit and Ansible 2.8.13.我正在使用 Ubuntu 服务器 20.04 64 位和 Ansible 2.8.13 构建 Ansible 服务器。 Among other things ansible will manage some mysql and postgres servers among other things.除其他外,ansible 将管理一些 mysql 和 postgres 服务器等。 In the near future there might be a version upgrade of ansible as well.在不久的将来可能还会有 ansible 的版本升级。 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.鉴于为了运行这些可执行文件,必须为每个 ansible 可执行文件编写包装脚本,以传递到主 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最后 map 是带有更新替代方案的主要可执行文件

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?这在 2021 年被认为是体面的方法还是有更好的方法?

Thanks,谢谢,

Actually after some more testing and reading this is what I came up with:实际上,经过更多的测试和阅读,这就是我想出的:

# Install
sudo apt-get -yqq install python3-pip python3-venv

sudo python3 -m venv --clear /opt/ansible

. /opt/ansible/bin/activate
pip3 install wheel
pip3 install ansible==2.8.13
deactivate

update-alternatives --install \
  /usr/local/bin/ansible-playbook ansible-playbook \
  /opt/ansible/bin/ansible-playbook 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM