diff options
author | uvok cheetah | 2025-02-02 14:56:00 +0100 |
---|---|---|
committer | uvok cheetah | 2025-02-02 14:56:00 +0100 |
commit | 91461cc8864a99494a81af42ea887a9058264c80 (patch) | |
tree | d837dcf167f713654d980a5ce5cd473e9036d7d1 | |
parent | ec2bdfc8fe0e10992ae9946d7e430b037ca9d1d4 (diff) |
Add conditional reboot timer
-rw-r--r-- | deploy-reboot.yml | 46 |
1 files changed, 46 insertions, 0 deletions
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 + |