added restic repository state

This commit is contained in:
= 2022-11-02 13:51:59 +01:00
parent 20c3717a10
commit e7626bdedc
3 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,8 @@
[Unit]
Description=Automount for restic repository
[Automount]
Where={{ pillar['restic']['repository']['mount'] }}
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=Mount the USB disk used as restic repository
[Mount]
What=/dev/disk/by-uuid/{{ pillar['restic']['repository']['disk_uuid'] }}
Where={{ pillar['restic']['repository']['mount'] }}
Type=auto
Options=defaults
[Install]
WantedBy=multi-user.target

27
restic/repository.sls Normal file
View File

@ -0,0 +1,27 @@
{% set escape_command = [ "systemd-escape -p", pillar['restic']['repository']['mount']]|join(" ") %}
{% set unit_name = salt['cmd.shell'](escape_command) %}
Create restic repository mount unit:
file.managed:
- name: /etc/systemd/system/{{ unit_name }}.mount
- source: salt://restic/files/restic.mount.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
Create restic repository automount unit:
file.managed:
- name: /etc/systemd/system/{{ unit_name }}.automount
- source: salt://restic/files/restic.automount.jinja
- template: jinja
- user: root
- group: root
- mode: "0644"
Run systemd daemon reload for repository:
cmd.run:
- name: systemctl daemon-reload
- onchanges:
- file: Create restic repository mount unit
- file: Create restic repository automount unit