作者:萌萌虾 | 来源:互联网 | 2023-01-10 15:33
当我在ops机器上运行命令时:
ansible web -b -l 192.168.31.101 -m yum -a "name=gcc state=latest"
它返回错误显示如下:
192.168.31.101 | FAILED! => {
"changed": false,
"failed": true,
"msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this module"
}
但是当我sudo yum install gcc
直接在上执行命令时192.168.31.101
,执行正确。
似乎ansible不能使用正确的yum和python
1> zimmer..:
我找到了解决方案,只需将python路径添加到hosts文件
ansible_python_interpreter=/usr/bin/python2.7