# Yum module problem

**URL:** <https://forum.ansible.com/t/yum-module-problem/11856>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [September 2, 2012, 12:32pm UTC](https://forum.ansible.com/t/yum-module-problem/11856 "2012-09-02T12:32:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 2, 2012, 12:32pm UTC](https://forum.ansible.com/t/yum-module-problem/11856/1 "2012-09-02T12:32:10Z")

</div>

The name is a package specification, so qualifiers like \>= and so on  
can be used at install time. I'm also not immediately sure whether  
those can be used at removal time, and haven't tried this yet, but:

instead of:

ansible el5-c1 -m yum -a "name=kernel-2.6.18-308.13.1.el5 state=removed"

try:

ansible el5-c1 -m yum -a "name=kernel=2.6.18-308.13.1 state=removed"

(be sure you're on latest Ansible 0.7)

if that doesn't work, you could also use the "installonlyn" yum plugin  
too, and then it's self managing. (Unless that's not  
recommended in yum anymore -- which I'm not sure of -- but it  
basically keeps the last N kernels around)

---

<div class="post-metadata">

**Author:** ![Steve\_Bernacki](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Steve\_Bernacki](https://forum.ansible.com/u/Steve_Bernacki)\
**Post date:** [September 2, 2012, 4:25pm UTC](https://forum.ansible.com/t/yum-module-problem/11856/2 "2012-09-02T16:25:00Z")

</div>

I tried this, no joy:

[steve@ansible ansible]$ ansible el5-c1 -m yum -a “name=kernel=2.6.18-308.13.1 state=removed”  
el5-c1 | FAILED \>\> {  
“changed”: false,  
“failed”: true,  
“item”: “”,  
“module”: “yum”,  
“msg”: “No Package matching ‘kernel=2.6.18-308.13.1’ found available, installed or updated”,  
“rc”: 0,  
“results”:   
}

Yum erase does catch it though:

[root@el5-c3 yum.repos.d]# yum erase kernel-2.6.18-308.13.1.el5  
Loaded plugins: fastestmirror  
Setting up Remove Process  
Resolving Dependencies  
 → Running transaction check  
—\> Package kernel.i686 0:2.6.18-308.13.1.el5 set to be erased

I can work around this with using shell or command for now. I’m no Python wiz but maybe I’ll look to see if I can’t submit a patch in case others run into this. Admittedly this is a bizarro corner case, but I figure I’d attack those straight away since ansible already works well for the normal stuff.

This is an excellent tool; I love the simplicity of it’s design, and the power that simplicity gives it.

Steve

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 2, 2012, 4:50pm UTC](https://forum.ansible.com/t/yum-module-problem/11856/3 "2012-09-02T16:50:17Z")

</div>

> I can work around this with using shell or command for now. I'm no Python wiz but maybe I'll look to see if I can't submit a patch in case others run into this. Admittedly this is a bizarro corner case, but I figure I'd attack those straight away since ansible already works well for the normal stuff.

Sounds good. I think the kernel case is pretty much the only time someone would try this and my version of CentOS ships with installonly\_limit=5, so yeah, I would agree it's a bit of a corner case. Patch would still be nice though.

> This is an excellent tool; I love the simplicity of it's design, and the power that simplicity gives it.

Glad you like it!
