# Proper way to do a yum update

**URL:** <https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767>\
**Category:** Ansible Project\
**Created:** [August 6, 2012, 5:09pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767 "2012-08-06T17:09:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 6, 2012, 5:09pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/1 "2012-08-06T17:09:18Z")

</div>

Hi,  
What is the proper way to do this?

action: yum name=update state=latest

Do I need to use the command action?

Thanks,  
James

---

<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:** [August 6, 2012, 5:14pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/2 "2012-08-06T17:14:24Z")

</div>

> Hi,  
> What is the proper way to do this?
> 
> action: yum name=update state=latest

To update a package named “update”? Exactly like you have it.

Assuming you mean update everything though.

> Do I need to use the command action?

Yes, but I would just update the packages you want updated, that way you have a more explicit configuration than updating whatever everyone may have installed.

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 6, 2012, 5:42pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/3 "2012-08-06T17:42:22Z")

</div>

Hi,  
I want to just do a yum update, to update a machine that has been just  
provisioned. But it seems to fail. I think I'm having trouble with  
the yum action:

TASK: [Make sure gcc is up to date] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [cl401.example.net] =\> {"changed": false, "failed": true,  
"item": "", "module": "yum", "msg": "No Package matching 'gcc' found  
available, installed or updated", "rc": 0, "results": ""}

This is in my yml file:

&nbsp;&nbsp;- name: Make sure gcc is up to date  
&nbsp;&nbsp;&nbsp;&nbsp;action: yum name=gcc state=latest

&nbsp;&nbsp;- name: Make sure ntpd is up to date  
&nbsp;&nbsp;&nbsp;&nbsp;action: yum name=ntpd state=latest

&nbsp;&nbsp;- name: Make sure the system is up to date  
&nbsp;&nbsp;&nbsp;&nbsp;action: yum name=update state=latest

Is this correct?

James

---

<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:** [August 6, 2012, 5:46pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/4 "2012-08-06T17:46:56Z")

</div>

> Hi,  
> I want to just do a yum update, to update a machine that has been just  
> provisioned. But it seems to fail. I think I’m having trouble with  
> the yum action:
> 
> TASK: [Make sure gcc is up to date] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> failed: [[cl401.example.net](http://cl401.example.net)] =\> {“changed”: false, “failed”: true,  
> “item”: “”, “module”: “yum”, “msg”: “No Package matching ‘gcc’ found  
> available, installed or updated”, “rc”: 0, “results”: “”}
> 
> This is in my yml file:
> 
> - name: Make sure gcc is up to date  
> action: yum name=gcc state=latest

Can you install a package named gcc with yum on the command line on this system? If not, it’s not available to you.

If you can, we have some other problem with the yum module and I guess it matters if you’re using RHN and what repos you are using and lots of other things.

Off topic, but you might as well use “with\_items” here too.

> - name: Make sure ntpd is up to date  
> action: yum name=ntpd state=latest
> 
> - name: Make sure the system is up to date  
> action: yum name=update state=latest

I feel like I’m repeating myself here, this last statement is definitely not correct, and you need to use the command module for that.

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 6, 2012, 5:57pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/5 "2012-08-06T17:57:48Z")

</div>

I hope this is helpful, I logged into the machine and did a sudo su -

[root@cl401 ~]# yum install gcc  
Loaded plugins: dellsysid, fastestmirror  
Loading mirror speeds from cached hostfile  
\* base: mirrors.kernel.org  
\* extras: mirror.stanford.edu  
\* updates: mirror.5ninesolutions.com  
Setting up Install Process  
Package gcc-4.1.2-52.el5\_8.1.x86\_64 already installed and latest version  
Nothing to do

So its already installed and the latest version, do I need to provide  
any other information?

Thanks,  
James

---

<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:** [August 6, 2012, 6:00pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/6 "2012-08-06T18:00:34Z")

</div>

What version of Ansible? Is this still 0.5?

If you are not using the latest git, please try with that and let us know.

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [August 6, 2012, 6:04pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/7 "2012-08-06T18:04:13Z")

</div>

can you check if you have yum-utils installed on that system?

rpm -q yum-utils

if not then:  
1. you need to install it  
2. you should update your checkout of ansible as a check for that has been pushed to there.

-sv

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 6, 2012, 6:53pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/8 "2012-08-06T18:53:33Z")

</div>

Hi,  
I'm running:  
sheepchase:CitrusLeaf jmarcus$ ansible --version  
ansible 0.6

Without updating ansible I was able to manually install yum-utils and  
then I was able to successfully run the gcc and ntp installs. In the  
future should I install yum-utils with the raw command?

Thanks for the help.

James

---

<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:** [August 6, 2012, 7:21pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/9 "2012-08-06T19:21:08Z")

</div>

The yum module should have yelled at you and given you a better error, though we would generally expect yum-utils to be part of @base in kickstart, per conversation in IRC.

If that’s not true, I’m generally of the opinion that if doing a package install and it needs it, we should try to ask yum to install yum-utils rather than get into an awkward bootstrapping case, but it seems  
to be true that it’s in @base. (yes?)

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [August 6, 2012, 7:25pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/10 "2012-08-06T19:25:51Z")

</div>

If you're using ansible from more recently than a 4 day old checkout the yum module should error out if you do not have repoquery installed:

[https://github.com/ansible/ansible/commit/fd492bebc6e544745bd0a85f2b069b7e54abfe75](https://github.com/ansible/ansible/commit/fd492bebc6e544745bd0a85f2b069b7e54abfe75)

make sure you're on the latest checkout of ansible.

thanks  
-sv

---

<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:** [August 6, 2012, 7:26pm UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/11 "2012-08-06T19:26:42Z")

</div>

From IRC discussion, it seems you may be running from an old git checkout.

Please update first, remove gcc and yum-utils, and try installing with ansible again to see if you get a better message.

---

<div class="post-metadata">

**Author:** ![Christian\_Laguerre](https://avatars.discourse-cdn.com/v4/letter/c/3bc359/32.png) [@Christian\_Laguerre](https://forum.ansible.com/u/Christian_Laguerre)\
**Post date:** [September 19, 2014, 5:22am UTC](https://forum.ansible.com/t/proper-way-to-do-a-yum-update/11767/12 "2014-09-19T05:22:58Z")

</div>

The answer to this is:

yum: name=\* state=latest
