summaryrefslogtreecommitdiff
path: root/deploy-reboot.yml
diff options
context:
space:
mode:
Diffstat (limited to 'deploy-reboot.yml')
-rw-r--r--deploy-reboot.yml46
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
+