zim*_*mer 4 python yum ansible centos7
当我在ops机器上运行命令时:
ansible web -b -l 192.168.31.101 -m yum -a "name=gcc state=latest"
Run Code Online (Sandbox Code Playgroud)
它返回错误显示如下:
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"
}
Run Code Online (Sandbox Code Playgroud)
但是当我sudo yum install gcc直接在上执行命令时192.168.31.101,执行正确。
似乎ansible不能使用正确的yum和python
我找到了解决方案,只需将python路径添加到hosts文件
ansible_python_interpreter=/usr/bin/python2.7
Run Code Online (Sandbox Code Playgroud)