Check yum module documentation and take a look on state attribute.
http://docs.ansible.com/ansible/yum_module.html
You use present which mean - check if package install and install if not.
If you want to upgrade use latest.
On Sunday, July 31, 2016 at 9:14:41 PM UTC+3, Giovanni Torres wrote:
>
> Running ansible 2.1.1.0 on CentOS 6.
>
> I have a package (v5.5.0) that is installed on the remote host:
>
> [remotehost ~] $ rpm -q mypkg
> mypkg-5.5.0-1.el6.x86_64
>
> I tried to use this command on the ansible server to update the package to
> v5.5.2 on the remotehost:
>
> # ansible remotehost -m yum -a
> "name=/nfs/RPMS/mypkg-5.5.2-1.el6.x86_64.rpm state=present" -vvvv
> remotehost | SUCCESS => {
> "changed": false,
> "invocation": {
> "module_args": {
> "conf_file": null,
> "disable_gpg_check": false,
> "disablerepo": null,
> "enablerepo": null,
> "exclude": null,
> "install_repoquery": true,
> "list": null,
> "name": [
> "/nfs/RPMS/mypkg-5.5.2-1.el6.x86_64.rpm"
> ],
> "state": "present",
> "update_cache": false,
> "validate_certs": true
> },
> "module_name": "yum"
> },
> "msg": "",
> "rc": 0,
> "results": []
> }
>
> But the package doesn't update. "changed" is false. It remains at 5.5.0,
> not 5.5.2 as expected.
>
>
> If i try to change state to latest, I get the following error:
>
> remotehost | FAILED! => {
> "changed": false,
> "failed": true,
> "invocation": {
> "module_args": {
> "conf_file": null,
> "disable_gpg_check": false,
> "disablerepo": null,
> "enablerepo": null,
> "exclude": null,
> "install_repoquery": true,
> "list": null,
> "name": [
> "/nfs/RPMS/mypkg-5.5.2-1.el6.x86_64.rpm"
> ],
> "state": "latest",
> "update_cache": false,
> "validate_certs": true
> },
> "module_name": "yum"
> },
> "msg": "No Package matching '/nfs/RPMS/mypkg-5.5.2-1.el6.x86_64.rpm'
> found available, installed or updated",
> "rc": 0,
> "results": []
> }
>
>
> But both machines mount this NFS share and I can stat the file on both the
> ansible server and the remotehost.
>
> Am I missing something obvious?
>
> Thanks,
> Giovanni
>
--
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/067e141b-4dce-4d45-81bb-821d5a4b3185%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.