ansible yum not working

China☆狼群 提交于 2019-12-22 09:19:30

问题


when i run command on the ops machine:

ansible web -b -l 192.168.31.101 -m yum -a "name=gcc state=latest"

it returns error shows below:

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" 
}

but when i execute the command sudo yum install gcc directly on 192.168.31.101, executed properly.

it seems like ansible can't use the right yum and python


回答1:


I find the solution, just add a python path to hosts file

ansible_python_interpreter=/usr/bin/python2.7



回答2:


this happened to me because i had python2.7 and python3 installed on my machin. ansible was using python3 and thus the error. so I had to explicitly specify it like below in my makefile target /bin/python2.7 /bin/ansible-playbook configure-box.yml



来源:https://stackoverflow.com/questions/47069450/ansible-yum-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!