如何在Debian系统中安装ansible-core 2.16版本
在Debian中安装ansible-core 2.16的步骤
方法一:通过pip安装(推荐新手)
Debian官方源的ansible-core版本滞后,用pip可直接指定版本,还能避免系统全局依赖冲突:
- 安装基础依赖:
sudo apt update && sudo apt install python3-pip python3-venv - 创建并激活虚拟环境(可选但推荐):
python3 -m venv ~/ansible-venv source ~/ansible-venv/bin/activate - 安装指定版本的ansible-core:
pip install ansible-core==2.16.9 # 可替换为2.16系列最新小版本 - 验证安装:
输出中应显示ansible --versionansible-core 2.16.x
方法二:通过Ansible官方APT仓库安装
如果偏好使用系统包管理器管理软件:
- 先卸载旧版本(若已安装):
sudo apt remove --purge ansible-core - 安装仓库依赖:
sudo apt update && sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common - 添加官方GPG密钥:
curl -fsSL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x93C4A3FD7BB9C367 | sudo gpg --dearmor -o /usr/share/keyrings/ansible-archive-keyring.gpg - 添加Ansible官方PPA仓库:
echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/ansible.list - 更新源并安装指定版本:
sudo apt update && sudo apt install ansible-core=2.16.* - 验证安装:
ansible --version
注意事项
- 使用虚拟环境时,每次使用Ansible前需执行
source ~/ansible-venv/bin/activate,也可将该命令添加到~/.bashrc实现自动激活 - 通过APT安装后,后续系统更新会自动升级ansible-core到2.16系列的最新小版本
内容的提问来源于stack exchange,提问作者Joel Ventura Ortiz
相关产品推荐
相关产品推荐

