# yum module doesn't update package

**URL:** <https://forum.ansible.com/t/yum-module-doesnt-update-package/13447>\
**Category:** Ansible Project\
**Created:** [September 10, 2013, 3:15pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447 "2013-09-10T15:15:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 10, 2013, 3:15pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/1 "2013-09-10T15:15:35Z")

</div>

Hi list,  
I’ve a strange problem here. I’ve a simple playbook to install monit like that :

- name: monit - install monit (if necessary)  
yum: name=monit enablerepo=rpmforge state=latest

However :  
If monit is already installed, the playbook returns “results”: [“All packages providing monit are up to date”], **whatever the version that is installed, and doesn’t update it.**  
I’ve backuped the script created by ansible on the target (something like /root/.ansible/tmp/ansible-xxxxx/yum), it returns the same message.  
But, I’ve tried locally (and manually) a yum update on the target, yum find the right version (5.5) on rpmforge repo, and propose to update it !  
And, definitely strange, if I remove monit on the target, the same playbook find and install the latest version 5.5 !

Any idea to try to debug that ??

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 10, 2013, 3:21pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/2 "2013-09-10T15:21:23Z")

</div>

Can you add a task beforehand to do a “yum clean all”, to see if perhaps it’s a yum caching issue?

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 10, 2013, 3:28pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/3 "2013-09-10T15:28:47Z")

</div>

Oh yes, I’ve tried that in the playbook, before the yum command, but not better…  
I’ve also deleted the /var/cache/yum directory content on the target.

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 10, 2013, 3:34pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/4 "2013-09-10T15:34:43Z")

</div>

To be sure :  
I’ve just tried the “yum clean all” manually on the target + remove /var/cache/yum/\*  
I must say that the yum command (in the playbook from the server, or locally with the python script that I backuped) is very slow, about 1 minute to finally say “up to date”, when a local yum command take about 10s.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 10, 2013, 3:40pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/5 "2013-09-10T15:40:37Z")

</div>

If the rpmforge repo is disabled by default, you might need to add --enablerepo=rpmforge to the yum clean call, otherwise yum will ignore it during the clean too.

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 10, 2013, 3:45pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/6 "2013-09-10T15:45:59Z")

</div>

Are you sure ? the clean option without enablerepo says ‘Cleaning up Everything’ and ‘Cleaning up list of fastest mirrors’, and same messages with enablerepo.  
Anyway, even with it, the playbook doesn’t update the package and says “up to date”.

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [September 10, 2013, 4:02pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/7 "2013-09-10T16:02:13Z")

</div>

Dear Frank,

I was going to ask you to try with specifying the latest version number, however i can see that the current yum module/documentation at least does not provide that option, it would useful option as for us we have certain environments that are capped as per vendor/solution certification and support matrix.

regards

Walid

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 10, 2013, 4:08pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/8 "2013-09-10T16:08:11Z")

</div>

Frank: Yes, I have run into that issue before where clean will not clean up disabled repos. Go ahead and file a github issue in regards to your problem if you would, and we will look into it.

Walid, that is not accurate. You can specify name=pkg-1.0 which will install a specific version.

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [September 10, 2013, 6:48pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/9 "2013-09-10T18:48:38Z")

</div>

James,

thank you, i stand corrected.

kind regards

Walid

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 11, 2013, 8:06am UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/10 "2013-09-11T08:06:37Z")

</div>

James,  
I spent some time to try to debug the python script created on the target. It seems that in is\_update function, the variables “pkgs” is always empty, so “my.returnPackagesByDep(pkgspec) + my.returnInstalledPackagesByDep(pkgspec)” and “my.pkgSack.matchPackageNames([pkgspec])” return nothing, but “pkgspec” is correctly filled with all possible versions of monit, including those in repo rpmforge.  
Do you know what should this YumBase module normally return ?

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 11, 2013, 2:57pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/11 "2013-09-11T14:57:36Z")

</div>

Well. I’ve tested a simple script like that :

import yum  
pkgspec=‘monit’  
my = yum.YumBase()  
my.repos.enableRepo(‘rpmforge’)  
print ‘RET=’,my.returnPackagesByDep(pkgspec),‘RET’  
print ‘INST=’,my.returnInstalledPackagesByDep(pkgspec)

This returns packages lists with pkgspec=‘monit’ like above, but nothing if I test with pkgspec=‘ **monit-5.5-1.el5.rf.i386** ’, which, if I’ve correctly traced the ansible script, is what it does…  
Please say if it can be a bug or if I made something wrong ?  
If bug, I’ll post all that as an issue on github.

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 12, 2013, 4:39pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/12 "2013-09-12T16:39:32Z")

</div>

Hi,  
digging in github/ansible, I find some tips. Finally, installing yum-utils (so repoquery) seems to solve this problem.  
But it seems also to me that it’s not a normal behavior, yes ? For now I install yum-util on all my servers.

Bye.  
Frank

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 12, 2013, 4:45pm UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/13 "2013-09-12T16:45:32Z")

</div>

That is actually a known issue we’re tracking on github ([https://github.com/ansible/ansible/issues/2002](https://github.com/ansible/ansible/issues/2002)). It was thought to only impact older RHEL versions talking to an RHN server, however it appears to be cropping up more on newer EL6 systems as well, so I’ll take a look at getting that fixed ASAP.

---

<div class="post-metadata">

**Author:** ![Frank\_Soyer](https://avatars.discourse-cdn.com/v4/letter/f/5daacb/32.png) [@Frank\_Soyer](https://forum.ansible.com/u/Frank_Soyer)\
**Post date:** [September 13, 2013, 8:21am UTC](https://forum.ansible.com/t/yum-module-doesnt-update-package/13447/14 "2013-09-13T08:21:31Z")

</div>

Thanks James,  
I’ve seen this issue, I took in it the idea of installing yum-utils, but it wasn’t clear because it is closed, first, and as you said concerns only RHN, on the other hand.  
Just keep in mind that I noted this problem on CentOS 5 (5.3, 5.4) systems as on CentOS 6 (6.3, 6.4).  
Maybe this issue can be reopen on github, I’ll can comment it with my tests, especially those showing that returnPackagesByDep seems to works with only the short package name (like “monit”) but not with the full name (“monit-5.5-1.el5.rf.i386”).

Best regards, and again thanks for the job done.  
Frank
