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: http://www.webmin.com/rpm.html): [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 - You can view the list of available versions of Webmin here: 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 * epel: mirror.slu.cz * extras: centos.mirrors.nublue.co.uk * updates: 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 ================================================================================================================= Package Arch Version Repository Size ================================================================================================================= Updating: webmin noarch 1.831-1 Webmin 27 M Transaction Summary ================================================================================================================= Upgrade 1 Package Total size: 27 M Is this ok [y/d/N]: n Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-02-01.13-26.9KDStM.yumtx # yum install 'webmin*1.49*' Loaded plugins: changelog, fastestmirror, keys, merge-conf, ps, remove-with-leaves, show-leaves, verify devops-artifacts | 1.5 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirror.mhd.uk.as44574.net * epel: mirror.slu.cz * extras: mirrors.vooservers.com * updates: mirror.sax.uk.as61049.net Resolving Dependencies --> Running transaction check ---> Package webmin.noarch 0:1.490-1 will be updated ---> Package webmin.noarch 0:1.499-1 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================= Package Arch Version Repository Size ================================================================================================================= Updating: webmin noarch 1.499-1 Webmin 15 M Transaction Summary ================================================================================================================= Upgrade 1 Package Total download size: 15 M Is this ok [y/d/N]: n Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-02-01.13-26.u8mk1v.yumtx The above hence explains why you are getting the behaviour you see. Ansible's yum module is doing a "yum update" instead of a "yum install". I don't know if the Ansible developers will see the above as a bug and the only workaround I can see is that you should setup an Ansible task to *uninstall* the package spec and then install it (with state=latest) which will force the Ansible yum module it to do a "yum install" and give you the behaviour you want. Regards, Jinesh -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8ac3d955-7b7f-4544-8649-7d012b8dab8b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
