# Ansible Yum Update revision from given version

**URL:** <https://forum.ansible.com/t/ansible-yum-update-revision-from-given-version/23574>\
**Category:** Ansible Project\
**Created:** [January 27, 2017, 10:29am UTC](https://forum.ansible.com/t/ansible-yum-update-revision-from-given-version/23574 "2017-01-27T10:29:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiago\_Silva](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Tiago\_Silva](https://forum.ansible.com/u/Tiago_Silva)\
**Post date:** [January 27, 2017, 10:29am UTC](https://forum.ansible.com/t/ansible-yum-update-revision-from-given-version/23574/1 "2017-01-27T10:29:29Z")

</div>

Im working on a project with several versions each version has it’s own revision in the repo

Example:  
fooproject-2.2.1-r4000.rpm  
fooproject-2.2.1-r4005.rpm

fooproject-3.0.1-r4015.rpm

There’s a server on version 2 rev 4000

doing the command-\> yum install fooproject_2.2.1_  
it will install → fooproject-2.2.1-r4005.rpm

now on ansible I created a task that does:

- name: Update fooproject revision  
yum:  
name: fooproject\*{{ foo\_version }}\*  
state: present

this will say that the server (in rev4000) is on the latest version

already tried

- name: Update fooproject revision  
yum:  
name: fooproject\*{{ foo\_version }}\*  
state: latest

and it will install version 3

Workaround at the moment:

Im using  
command: yum install

Is there a way to use the yum module for this case?

---

<div class="post-metadata">

**Author:** ![Jinesh\_Choksi](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jinesh\_Choksi](https://forum.ansible.com/u/Jinesh_Choksi)\
**Post date:** [February 1, 2017, 1:52pm UTC](https://forum.ansible.com/t/ansible-yum-update-revision-from-given-version/23574/2 "2017-02-01T13:52:13Z")

</div>

Hi Tiago,

Although you have provided sufficient information, it was not a simple matter to try to reproduce the issue. 🙂

Here are some instructions for anyone wanting to try to reproduce this:

I chose to use webmin as the package to test with since I had easy access to it.

- Setup a /etc/yum.repos.d/webmin.repo file with the following contents (source: [Downloading and Installing | Webmin](http://www.webmin.com/rpm.html)):

`

[Webmin]  
name=Webmin Distribution Neutral  
#baseurl=[Index of /download/yum](http://download.webmin.com/download/yum)  
mirrorlist=[http://download.webmin.com/download/yum/mirrorlist](http://download.webmin.com/download/yum/mirrorlist)  
enabled=1

`

- Fetch and install the GPG key:

`

wget [http://www.webmin.com/jcameron-key.asc](http://www.webmin.com/jcameron-key.asc)  
rpm --import jcameron-key.asc

`

- You can view the list of available versions of Webmin here: [http://download.webmin.com/download/yum/](http://download.webmin.com/download/yum/)

- For the reproduction, install, say version: webmin-1.490-1.noarch

`

yum install webmin-1.490-1

`

Now, you should be in a position to test the Ansible tasks Tiago provided as examples. i.e.

`

- name: Update webmin revision  
yum:  
name: “webmin_1.49_”  
state: present

`

and

`

- name: Update Webmin revision  
yum:  
name: “webmin_1.49_”  
state: latest

`

I looked at the code for the Ansible yum module and I believe that the correct state that you should be using for your purposes is: “latest”.

I believe the reason the issue occurs is that on [line 905](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/yum.py#L905), the is\_installed function returns true because it works out that the package is indeed installed and it then adds the specified package spec (webmin_1.49_) to the list of packages that need “updating” instead of the list of packages which need “installing”.

So this means that the Ansible yum module will be carrying out an action equivalent to:

`  
yum update ‘webmin_1.49_’

`

instead of:

`  
yum install ‘webmin_1.49_’

`

If you run those two commands manually on the command line, this the output you would see:

`

# yum update ‘webmin_1.49_’

Loaded plugins: changelog, fastestmirror, keys, merge-conf, ps, remove-with-leaves, show-leaves, verify  
Loading mirror speeds from cached hostfile

- base: [centos.mirrors.nublue.co.uk](http://centos.mirrors.nublue.co.uk)
- epel: mirror.slu.cz
- extras: [centos.mirrors.nublue.co.uk](http://centos.mirrors.nublue.co.uk)
- updates: [mirrors.vooservers.com](http://mirrors.vooservers.com)  
Resolving Dependencies  
 → Running transaction check  
—\> Package webmin.noarch 0:1.490-1 will be updated  
—\> Package webmin.noarch 0:1.831-1 will be an update  
 → Finished Dependency Resolution

Dependencies Resolved
