blob: 078d6cde7962b770c76f4cbbf23348b4bf17f27f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
---
- name: Deploy conditional reboot service and timer
hosts: all
become: true
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'
mode: "0640"
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
mode: "0640"
notify:
- Reload systemd
- name: Enable and start conditional-reboot.timer
systemd:
name: conditional-reboot.timer
enabled: true
state: started
handlers:
- name: Reload systemd
systemd:
daemon_reload: true
|