ansible-pull(role): fix timestamp export permission issue

The successful run timestamp export didn't work, because the
ansible-pull user wouldn't necessarily have the necessary permissions.
Move the timestamp export as well as the reboot to separate services,
which always run as root, to ensure these operations work.
This commit is contained in:
June 2026-11-04 15:03:41 +01:00
commit 9678f4dd83
Signed by: june
SSH key fingerprint: SHA256:o9EAq4Y9N9K0pBQeBTqhSDrND5E7oB+60ZNx0U1yPe0
2 changed files with 32 additions and 4 deletions

View file

@ -0,0 +1,8 @@
[Unit]
Description=ansible-pull reboot, if required
After=ansible-pull.service
[Service]
Type=oneshot
# Reboot, if /var/run/reboot-required or /var/run/ansible-reboot-required exist.
ExecStart=/usr/bin/bash -c 'if [ -e /var/run/reboot-required ] || [ -e /var/run/ansible-reboot-required ]; then systemctl reboot; fi'

View file

@ -0,0 +1,8 @@
[Unit]
Description=ansible-pull successful run timestamp exporter
After=ansible-pull.service
Before=ansible-pull-reboot.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'echo "ansible_pull_last_successful_run_timestamp_seconds $(date +%s)" > /var/lib/node_exporter_textfile/ansible_pull.prom.$$; mv /var/lib/node_exporter_textfile/ansible_pull.prom.$$ /var/lib/node_exporter_textfile/ansible_pull.prom'