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.
`
[Webmin]
name=Webmin Distribution Neutral
#baseurl=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
rpm --import jcameron-key.asc
`
`
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: “webmin1.49”
state: present
`
and
`
- name: Update Webmin revision
yum:
name: “webmin1.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, the is_installed function returns true because it works out that the package is indeed installed and it then adds the specified package spec (webmin1.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 ‘webmin1.49’
`
instead of:
`
yum install ‘webmin1.49’
`
If you run those two commands manually on the command line, this the output you would see:
`
yum update ‘webmin1.49’
Loaded plugins: changelog, fastestmirror, keys, merge-conf, ps, remove-with-leaves, show-leaves, verify
Loading mirror speeds from cached hostfile
Dependencies Resolved