fix: dont use Yum/Rpm task when packages are already installed
This should fix issue #225
This basically bypasses the real functionality of
ansible.builtin.package. Rather than have a hacky workaround, we should probably switch toansible.builtin.yumdirectly. 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
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": []}
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.
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
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.
created new issue: https://github.com/ansible/ansible/issues/81847
https://github.com/prometheus-community/ansible/issues/225#issuecomment-2419535914
Docs Build 📝
This PR is closed and any previously published docsite has been unpublished.