ansible icon indicating copy to clipboard operation
ansible copied to clipboard

fix: dont use Yum/Rpm task when packages are already installed

Open avdland opened this issue 2 years ago • 6 comments

This should fix issue #225

avdland avatar Sep 28 '23 08:09 avdland

This basically bypasses the real functionality of ansible.builtin.package. Rather than have a hacky workaround, we should probably switch to ansible.builtin.yum directly. This would allow tweaking the offline behavior with controlling the metadata update flags.

Agreed, but there is no need to switch to the yum module, the package module is actually just a proxy on top of the yum module, which means you can pass any of the yum module parameters to the package module

gardar avatar Sep 28 '23 11:09 gardar

While testing, I had set the cacheonly parameter to true, but then it complained that the cache was empty, and the task would still fail... fatal: [vm]: FAILED! => {"changed": false, "msg": "Cache-only enabled but no cache for 'rhel-9-for-x86_64-supplementary-rhui-rpms'", "rc": 1, "results": []}

avdland avatar Sep 28 '23 12:09 avdland

It seems that the disablerepo parameter does what I want. I've added a new variable, node_exporter_offline, which then disables the repos if true.

avdland avatar Sep 29 '23 09:09 avdland

I do think the previous commit https://github.com/prometheus-community/ansible/commit/b41c938919a749c9adcdeba6b29f552ae6cca531 is a better solution though... we shouldnt even have to run yum commands if the package is already installed

avdland avatar Sep 29 '23 11:09 avdland

IMO this is a bug in Ansible's package module. It should not need to update caches or activate yum with state: present.

We have this issue with every role, they all depend on selinux. Not just node_exporter.

SuperQ avatar Sep 29 '23 14:09 SuperQ

created new issue: https://github.com/ansible/ansible/issues/81847

avdland avatar Oct 03 '23 09:10 avdland

https://github.com/prometheus-community/ansible/issues/225#issuecomment-2419535914

gardar avatar Oct 17 '24 13:10 gardar

Docs Build 📝

This PR is closed and any previously published docsite has been unpublished.

github-actions[bot] avatar Oct 17 '24 13:10 github-actions[bot]