fix: skip process_exporter and systemd_exporter restart handlers in check mode#818
Open
reech-thibault wants to merge 1 commit into
Open
Conversation
…heck mode
The process_exporter and systemd_exporter restart handlers invoke the
systemd module unconditionally. In check mode against a host where the
service has never been deployed, the unit file is not actually written,
so the notified restart handler fails with:
Could not find the requested service process_exporter: host
Every other exporter role (node_exporter, redis_exporter, mysqld_exporter,
...) already guards its restart handler with `when: not ansible_check_mode`.
These two roles were missed. Apply the same guard for consistency so a
`--check` run succeeds on a not-yet-provisioned host.
Signed-off-by: Thibault de Froissard <thibault@reech.com>
36bbea9 to
daf9ce0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add
when: not ansible_check_modeto the restart handlers of theprocess_exporterandsystemd_exporterroles.Why
In check mode against a host where the service has never been deployed, the
Create systemd service unittask reportschangedbut does not actually write the.servicefile, then notifies the restart handler. When handlers flush, theansible.builtin.systemdcall withstate: restartedtargets a unit that does not exist, and the run fails:This makes
ansible-playbook --checkunusable as a pre-deploy gate on a not-yet-provisioned host.Consistency
Every other exporter role already guards its restart handler this way —
node_exporter,redis_exporter,mysqld_exporter,postgres_exporter,cadvisor, and 13 more. Onlyprocess_exporterandsystemd_exporterwere missed; this PR aligns them with the rest.No functional change outside check mode.
🤖 Generated with Claude Code