1.Python环境切换

之前ansible旧版本可以用pthon2.7.5,升级到2.9以后的新版本所以需要切换为python3
这里安装路径是/usr/local/bin,可根据实际路径修改
先删除软连接,就是python系统默认的快捷方式

rm -rf /usr/bin/python
rm -rf /usr/bin/pip
ln -s /usr/local/bin/python3 /usr/bin/python
ln -s /usr/local/bin/pip3 /usr/bin/pip

2.pip安装ansible-2.9.10升级

pip install ansible-2.9.10.tar.gz
pip -V
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
python -V
Python 3.6.9

ansible --version
ansible 2.9.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Oct 15 2019, 16:15:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐