Skip to content

fix: skip process_exporter and systemd_exporter restart handlers in check mode#818

Open
reech-thibault wants to merge 1 commit into
prometheus-community:mainfrom
reech-thibault:fix/exporter-handler-check-mode
Open

fix: skip process_exporter and systemd_exporter restart handlers in check mode#818
reech-thibault wants to merge 1 commit into
prometheus-community:mainfrom
reech-thibault:fix/exporter-handler-check-mode

Conversation

@reech-thibault

Copy link
Copy Markdown

What

Add when: not ansible_check_mode to the restart handlers of the process_exporter and systemd_exporter roles.

Why

In check mode against a host where the service has never been deployed, the Create systemd service unit task reports changed but does not actually write the .service file, then notifies the restart handler. When handlers flush, the ansible.builtin.systemd call with state: restarted targets a unit that does not exist, and the run fails:

RUNNING HANDLER [prometheus.prometheus.process_exporter : Restart process_exporter]
fatal: [host]: FAILED! => {"changed": false, "msg": "Could not find the requested service process_exporter: host"}

This makes ansible-playbook --check unusable 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. Only process_exporter and systemd_exporter were missed; this PR aligns them with the rest.

  when:
    - not ansible_check_mode

No functional change outside check mode.

🤖 Generated with Claude Code

@reech-thibault reech-thibault marked this pull request as draft June 16, 2026 12:58
@reech-thibault reech-thibault marked this pull request as ready for review June 16, 2026 12:59
…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>
@reech-thibault reech-thibault force-pushed the fix/exporter-handler-check-mode branch from 36bbea9 to daf9ce0 Compare June 16, 2026 13:03
@github-actions github-actions Bot added bugfix and removed bugfix labels Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant