From 91461cc8864a99494a81af42ea887a9058264c80 Mon Sep 17 00:00:00 2001 From: uvok cheetah Date: Sun, 2 Feb 2025 14:56:00 +0100 Subject: Add conditional reboot timer --- deploy-reboot.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 deploy-reboot.yml (limited to 'deploy-reboot.yml') diff --git a/deploy-reboot.yml b/deploy-reboot.yml new file mode 100644 index 0000000..de7bed7 --- /dev/null +++ b/deploy-reboot.yml @@ -0,0 +1,46 @@ +--- +- name: Deploy conditional reboot service and timer + hosts: all + become: yes + + tasks: + - name: Copy conditional-reboot.service file + copy: + dest: /etc/systemd/system/conditional-reboot.service + content: | + [Unit] + Description=Service to conditionally reboot the system if /var/run/reboot-required exists + + [Service] + Type=oneshot + ExecStart=/bin/sh -c 'if [ -f /var/run/reboot-required ]; then reboot; fi' + notify: + - reload systemd + + - name: Copy conditional-reboot.timer file + copy: + dest: /etc/systemd/system/conditional-reboot.timer + content: | + [Unit] + Description=Timer to run conditional reboot service daily at 1:30 AM + + [Timer] + OnCalendar=daily 01:30:00 + Persistent=true + + [Install] + WantedBy=timers.target + notify: + - reload systemd + + - name: Enable and start conditional-reboot.timer + systemd: + name: conditional-reboot.timer + enabled: yes + state: started + + handlers: + - name: reload systemd + systemd: + daemon_reload: yes + -- cgit v1.2.3