Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible yum not working

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

like image 412
zimmer Avatar asked Nov 02 '17 07:11

zimmer


People also ask

What is yum command in Ansible?

Ansible's yum module is used to manage packages with the yum package manager, which is the default on Red Hat based Linux distributions such as Red Hat Enterprise Linux and CentOS. Most systems require root/superuser permissions to manage packages, which means that become: true is required.

Can we enable or disable repo using yum module Ansible?

This module is part of ansible-core and included in all Ansible installations. In most cases, you can use the short module name yum_repository even without specifying the collections: keyword.

How do I install Ansible packages?

Package installation is a relatively simple task and only requires two elements. The state option instructs Ansible to check whether or not some package is present on the system, and the name option lists which packages to look for. Ansible deals in machine state, so module instructions always imply change.


1 Answers

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

ansible_python_interpreter=/usr/bin/python2.7
like image 191
zimmer Avatar answered Oct 17 '22 02:10

zimmer