homeserver/roles/mgrote_restic/tasks/main.yml
Michael Grote bc6f8fdc9e
All checks were successful
ansible-lint / gitleaks (push) Successful in 5s
ansible-lint / Ansible Lint (push) Successful in 1m0s
add no_log as global variable (#233)
Reviewed-on: #233
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Co-committed-by: Michael Grote <michael.grote@posteo.de>
2024-11-10 15:56:59 +01:00

117 lines
2.6 KiB
YAML

---
- name: ensure group exists
become: true
ansible.builtin.group:
name: "{{ restic_group }}"
state: present
- name: install restic-packages
become: true
ansible.builtin.package:
name:
- restic
state: present
- name: create "{{ restic_conf_dir }}"
become: true
ansible.builtin.file:
path: "{{ restic_conf_dir }}"
state: directory
owner: "{{ restic_user }}"
group: "{{ restic_group }}"
mode: "0755"
- name: template smb.cred
become: true
ansible.builtin.template:
src: "smb.cred.j2"
dest: "{{ restic_conf_dir }}/smb.cred"
owner: "{{ restic_user }}"
group: "{{ restic_group }}"
mode: "0600"
no_log: "{{ no_debug | default('true') }}"
- name: templates excludes
become: true
ansible.builtin.blockinfile:
path: "{{ restic_conf_dir }}/excludes"
create: true
block: "{{ restic_exclude }}"
mode: "0644"
owner: "{{ restic_user }}"
group: "{{ restic_group }}"
- name: template restic.env
become: true
ansible.builtin.template:
src: "restic.env.j2"
dest: "{{ restic_conf_dir }}/restic.env"
owner: root
group: root
mode: "0600"
no_log: "{{ no_debug | default('true') }}"
- name: template restic.mount
become: true
ansible.builtin.template:
src: media-restic.mount.j2
dest: /etc/systemd/system/media-restic.mount # media-restic == /media/restic
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- systemctl enable units
- name: template restic.automount
become: true
ansible.builtin.template:
src: media-restic.automount.j2
dest: /etc/systemd/system/media-restic.automount
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- systemctl enable units
- systemctl start units
- name: template restic.service
become: true
ansible.builtin.template:
src: restic.service.j2
dest: /etc/systemd/system/restic.service
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- name: template restic.timer
become: true
ansible.builtin.template:
src: restic.timer.j2
dest: /etc/systemd/system/restic.timer
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- name: template restic_mail.service
become: true
ansible.builtin.template:
src: "restic_mail.service.j2"
dest: /etc/systemd/system/restic_mail.service
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- name: systemctl start restic.timer
become: true
ansible.builtin.systemd:
name: restic.timer
state: started
enabled: true