Compare commits

...

1 Commits

2 changed files with 36 additions and 2 deletions

View File

@ -44,14 +44,22 @@
- name: Ensure systemd service file for '{{ restic_job_name }}' is templated
template:
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.service"
src: restic.service.j2
dest: "/etc/systemd/system/{{ service.unit_name }}.service"
src: "{{ service.file }}"
owner: root
group: root
mode: 0640
notify:
- reload-systemd
- trigger-restic
loop:
- unit_name: "{{ restic_systemd_unit_naming_scheme }}"
file: restic.service.j2
- unit_name: "{{ restic_systemd_unit_naming_scheme }}-unlock"
file: restic-unlock.service.j2
loop_control:
loop_var: service
label: "{{ service.file }}"
- name: Ensure systemd service file for '{{ restic_job_name }}' is templated
template:
@ -66,6 +74,11 @@
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
meta: flush_handlers
- name: Ensure systemd service for unlocking repository for '{{ restic_job_name }}' is enabled
systemd:
name: "{{ restic_systemd_unit_naming_scheme }}-unlock.service"
enabled: true
- name: Ensure systemd timer for '{{ restic_job_name }}' is activated
systemd:
name: "{{ restic_systemd_unit_naming_scheme }}.timer"

View File

@ -0,0 +1,21 @@
[Unit]
Description={{ restic_job_description }} - Unlock after reboot job
[Service]
Type=oneshot
User={{ restic_user }}
WorkingDirectory={{ restic_systemd_working_directory }}
SyslogIdentifier={{ restic_systemd_syslog_identifier }}
Environment=RESTIC_REPOSITORY={{ restic_repo_url }}
Environment=RESTIC_PASSWORD={{ restic_repo_password }}
{% if restic_s3_key_id and restic_s3_access_key %}
Environment=AWS_ACCESS_KEY_ID={{ restic_s3_key_id }}
Environment=AWS_SECRET_ACCESS_KEY={{ restic_s3_access_key }}
{% endif %}
ExecStartPre=-/bin/sh -c '/usr/bin/restic snapshots || /usr/bin/restic init'
ExecStart=/usr/bin/restic unlock
[Install]
WantedBy=multi-user.target