Compare commits

..
Author SHA1 Message Date
f1545e6dc2 Update all stable non-major dependencies
All checks were successful
/ build (pull_request) Successful in 54s
/ Ansible Lint (push) Successful in 3m50s
/ Ansible Lint (pull_request) Successful in 3m52s
2026-11-04 20:17:04 +00:00
947d8fd0a0
ansible-pull(role): deploy failure notify service using the copy loop
All checks were successful
/ build (pull_request) Successful in 32s
/ build (push) Successful in 37s
/ cleanup-staging (pull_request) Successful in 41s
/ Ansible Lint (pull_request) Successful in 3m47s
/ Ansible Lint (push) Successful in 3m45s
Deploy the ansible-pull-failure-notify.service using the loop using
ansible.builtin.copy as it doesn't have any template logic.
2026-11-04 17:28:05 +01:00
a4a92448dc
ansible-pull(role): have failure notify deploy match other script deploy
Have the deployment of the ansible-pull-failure-notify script match the
deployment of the other helper scripts.
2026-11-04 17:28:05 +01:00
96a7eabbac
ansible-pull(role): move ansible-pull reboot logic to script as well
Do this to unify the way these helper scripts get deployed.
2026-11-04 17:28:05 +01:00
1157c98ff5
ansible-pull(role): make successful run timestamp exporter work
The successful run timestamp exporter didn't work, because the
ansible-pull user wouldn't necessarily have the necessary permissions
and because the command wouldn't properly work.
Move the timestamp export as well as the reboot to separate services,
which always run as root, to ensure these operations work and to have a
clean setup using systemd services.
Also move the successful run timestamp exporter to a custom script to
have it work properly.
2026-11-04 17:28:03 +01:00
7 changed files with 61 additions and 8 deletions

View file

@ -0,0 +1,7 @@
[Unit]
Description=ansible-pull failure notifier
[Service]
Type=oneshot
ExecStart=ansible-pull-failure-notify
User=root

View file

@ -0,0 +1,7 @@
[Unit]
Description=ansible-pull reboot, if required
After=ansible-pull.service
[Service]
Type=oneshot
ExecStart=ansible-pull-reboot

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Reboot, if /var/run/reboot-required or /var/run/ansible-reboot-required exist.
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=ansible-pull-successful-run-timestamp-exporter

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
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

View file

@ -24,14 +24,28 @@
virtualenv: /usr/local/lib/ansible_pull_venv
become: true
- name: ensure ansible-pull-failure-notify script installation exists
ansible.builtin.template:
src: ansible-pull-failure-notify.sh.j2
dest: /usr/local/sbin/ansible-pull-failure-notify.sh
- name: ensure helper script installations exist
ansible.builtin.copy:
src: "{{ item }}.sh"
dest: "/usr/local/sbin/{{ item }}"
owner: root
group: root
mode: "0755"
become: true
loop:
- ansible-pull-successful-run-timestamp-exporter
- ansible-pull-reboot
- name: ensure templated helper script installations exists
ansible.builtin.template:
src: "{{ item }}.sh.j2"
dest: "/usr/local/sbin/{{ item }}"
owner: root
group: root
mode: "0755"
become: true
loop:
- ansible-pull-failure-notify
- name: ensure secrets directory exists
ansible.builtin.file:
@ -51,7 +65,7 @@
group: "{{ ansible_pull__user }}"
become: true
- name: ensure systemd services exists
- name: ensure templated systemd services exists
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
@ -61,7 +75,21 @@
become: true
loop:
- ansible-pull.service
notify:
- systemd daemon reload
- name: ensure systemd services exists
ansible.builtin.copy:
src: "{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
owner: root
group: root
mode: "0644"
become: true
loop:
- ansible-pull-failure-notify.service
- ansible-pull-reboot.service
- ansible-pull-successful-run-timestamp-exporter.service
notify:
- systemd daemon reload

View file

@ -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'