prometheus-community / ansible

Ansible Collection for Prometheus
https://prometheus-community.github.io/ansible/
Apache License 2.0
393 stars 133 forks source link

fix(blackbox_exporter): make capability setting idempotent #438

Closed sverrehu closed 1 month ago

sverrehu commented 1 month ago

Recently, the "Ensure blackbox exporter binary has cap_net_raw capability" task has reported a change for every pipeline run. This PR contains two changes to fix this behavior.

With these changes, our pipeline reports no change if the cap_net_raw is as wanted, and reports change otherwise.

erikgb commented 1 month ago

@gardar Could this be the culprit task causing Prometheus always to restart, ref. https://github.com/prometheus-community/ansible/pull/431#issuecomment-2422526033?

SuperQ commented 1 month ago

This wouldn't case Prometheus to restart, only the blackbox_exporter.

SuperQ commented 1 month ago

This needs a DCO sign-off. You can use git commit -s --amend to add it.

sverrehu commented 1 month ago

I noticed some idempotence checks failed. Before this PR, those tests would in effect have changed_when: false, as molecule-idempotence-notest was part of ansible_skip_tags in Molecule's idempotence checks.

I just added molecule-idempotence-notest as part of the tags, in order to skip this task completely during Molecule's idempotence checks. Hopefully, the effect should be the same as before, but without having any effect when running outside of Molecule.

PS: The reason it fails on Ubuntu 20.04 is that getcap on that version returns cap_net_raw+ep no matter how we set it. On other platforms, getcap returns cap_net_raw=ep.

gardar commented 1 month ago

The failing CI tests will be fixed with #440