最近在装Ansible,有一台受控端Ubuntu16的服务器,安装了Python2.7.12和Pyhon3.5。当用Ansible连接它时,显示使用的是Python3.5。最后看文档,发现Ansible可以在hosts的文件中指定受控服上运行的Python。
python2 --version
Python 2.7.12
python3 --version
Python 3.5.2
ansible 192.168.8.101 -m shell -a 'ip a| grep 192.168.'
192.168.8.101 | FAILED | rc=-1 >>
ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.6. Current version: 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609]
vim /etc/ansible/hosts
192.168.8.101 ansible_python_interpreter=/usr/bin/python2.7
ansible 192.168.8.101 -m shell -a 'ip a| grep 192.168.'
192.168.8.101 | CHANGED | rc=0 >>
inet 192.168.8.101/24 brd 192.168.8.255 scope global eno1