Add daily/weekly systemd timer setup
This commit is contained in:
parent
0e78c4a642
commit
636019283f
7 changed files with 104 additions and 2 deletions
13
roles/arch/handlers/main.yml
Normal file
13
roles/arch/handlers/main.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
- name: enable daily timer
|
||||||
|
systemd:
|
||||||
|
name: daily.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon-reload: yes
|
||||||
|
|
||||||
|
- name: enable weekly timer
|
||||||
|
systemd:
|
||||||
|
name: weekly.timer
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon-reload: yes
|
||||||
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# - network setup (laptop)
|
# - network setup (laptop)
|
||||||
# - daily systemd-timer
|
|
||||||
# - weekly systemd-timer
|
|
||||||
# - reflector setup
|
# - reflector setup
|
||||||
# - pacman setup depending on platform (see include section for common options)
|
# - pacman setup depending on platform (see include section for common options)
|
||||||
|
|
||||||
|
|
@ -41,3 +39,4 @@
|
||||||
- include_tasks: syncthing.yml # TODO depending on platform
|
- include_tasks: syncthing.yml # TODO depending on platform
|
||||||
- include_tasks: git.yml # TODO (identify)
|
- include_tasks: git.yml # TODO (identify)
|
||||||
- include_tasks: openvpn.yml # TODO depending on platform
|
- include_tasks: openvpn.yml # TODO depending on platform
|
||||||
|
- include_tasks: timer.yml
|
||||||
|
|
|
||||||
47
roles/arch/tasks/timer.yml
Normal file
47
roles/arch/tasks/timer.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
- name: copy timer files
|
||||||
|
become: yes
|
||||||
|
template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
owner: root
|
||||||
|
mode: "0644"
|
||||||
|
loop:
|
||||||
|
- {
|
||||||
|
src: "timer/daily_timer.j2",
|
||||||
|
dest: "/etc/systemd/system/daily.timer",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "timer/weekly_timer.j2",
|
||||||
|
dest: "/etc/systemd/system/weekly.timer",
|
||||||
|
}
|
||||||
|
notify:
|
||||||
|
- enable daily timer
|
||||||
|
- enable weekly timer
|
||||||
|
|
||||||
|
- name: copy target files
|
||||||
|
become: yes
|
||||||
|
template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
owner: root
|
||||||
|
mode: "0644"
|
||||||
|
loop:
|
||||||
|
- {
|
||||||
|
src: "timer/daily_target.j2",
|
||||||
|
dest: "/etc/systemd/system/daily.target",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "timer/weekly_target.j2",
|
||||||
|
dest: "/etc/systemd/system/weekly.target",
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: create target directories
|
||||||
|
become: yes
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
mode: "0755"
|
||||||
|
loop:
|
||||||
|
- "/etc/systemd/system/daily.target.wants"
|
||||||
|
- "/etc/systemd/system/weekly.target.wants"
|
||||||
9
roles/arch/templates/timer/daily_target.j2
Normal file
9
roles/arch/templates/timer/daily_target.j2
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
#
|
||||||
|
# Add the following to your service unit to make use of this target:
|
||||||
|
# Wants=daily.target
|
||||||
|
#
|
||||||
|
# Or symlink the unit file to the daily.target.wants directory manually
|
||||||
|
[Unit]
|
||||||
|
Description=Daily timer target
|
||||||
|
Requires=multi-user.target
|
||||||
12
roles/arch/templates/timer/daily_timer.j2
Normal file
12
roles/arch/templates/timer/daily_timer.j2
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
#
|
||||||
|
[Unit]
|
||||||
|
Description=Timer which runs all services on a daily basis inside the daily.target.wants directory
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
Unit=daily.target
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
10
roles/arch/templates/timer/weekly_target.j2
Normal file
10
roles/arch/templates/timer/weekly_target.j2
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
#
|
||||||
|
# Add the following to your service unit to make use of this target:
|
||||||
|
# Wants=weekly.target
|
||||||
|
#
|
||||||
|
# Or symlink the unit file to the weekly.target.wants directory manually
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Weekly timer target
|
||||||
|
Requires=multi-user.target
|
||||||
12
roles/arch/templates/timer/weekly_timer.j2
Normal file
12
roles/arch/templates/timer/weekly_timer.j2
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
#
|
||||||
|
[Unit]
|
||||||
|
Description=Timer which runs all services on a weekly basis inside the weekly.target.wants directory
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=weekly
|
||||||
|
Unit=weekly.target
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Add table
Add a link
Reference in a new issue