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:
parent
f6f6cc4804
commit
9678f4dd83
1 changed files with 32 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ Description=ansible-pull for configuration and maintenance
|
|||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
OnFailure=ansible-pull-failure-notify.service
|
||||
OnSuccess=ansible-pull-successful-run-timestamp-exporter.service ansible-pull-reboot.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
|
@ -19,6 +20,3 @@ ExecStart=/usr/local/lib/ansible_pull_venv/bin/ansible-pull \
|
|||
--inventory "{{ ansible_pull__inventory }}" \
|
||||
"{{ ansible_pull__playbook }}"
|
||||
User={{ ansible_pull__user }}
|
||||
ExecStartPost=/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'
|
||||
# Reboot, if /var/run/reboot-required or /var/run/ansible-reboot-required exist.
|
||||
ExecStartPost=/usr/bin/bash -c 'if [ -e /var/run/reboot-required ] || [ -e /var/run/ansible-reboot-required ]; then sudo systemctl reboot; fi'
|
||||
|
|
|
|||
Loading…
Reference in a new issue