![Ansible 为 root 用户和非 root 用户显示不同的版本](https://linux22.com/image/1178784/Ansible%20%E4%B8%BA%20root%20%E7%94%A8%E6%88%B7%E5%92%8C%E9%9D%9E%20root%20%E7%94%A8%E6%88%B7%E6%98%BE%E7%A4%BA%E4%B8%8D%E5%90%8C%E7%9A%84%E7%89%88%E6%9C%AC.png)
我需要使用旧版本的 Ansible (2.9)。我使用添加了 repo add-apt-repository ppa:ansible/ansible-2.9
。当我ansible --version
以 root 身份运行时,我得到:
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
但是,当我以普通用户身份运行相同的命令时,我得到:
ansible 2.10.3
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/christopher/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/christopher/.local/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
我有不不知道发生了什么。我现在甚至无法使用 Ansible,因为每个剧本都会崩溃,因为它无法识别诸如 之类的模块package
。我在哪里可以找到这个 2.10.3 版本并摆脱它!?
答案1
pip3 list
成立ansible-base 2.10.3
pip3 uninstall ansible-base
在我和 sudo 上都运行过ansible --version
。现在都是 2.9.6
ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
以 root 身份
ansible --version
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]