homeserver/roles/mgrote_restic/tasks/main.yml
Michael Grote 4972eeef96
All checks were successful
ansible-lint / gitleaks (push) Successful in 5s
ansible-lint / Ansible Lint (push) Successful in 29s
add laptop setup (#268)
Reviewed-on: #268
2024-12-30 20:06:25 +01:00

77 lines
1.8 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: Ensure systemd services are templated
become: true
ansible.builtin.template:
src: "{{ item }}.j2"
dest: /etc/systemd/system/{{ item }}
owner: root
group: root
mode: "0644"
notify:
- systemctl daemon-reload
- systemctl enable units
loop:
- media-restic.mount # media-restic == /media/restic
- media-restic.automount # media-restic == /media/restic
- restic.service
- restic.timer
- restic_mail.service
- name: systemctl start restic.timer
become: true
ansible.builtin.systemd:
name: restic.timer
state: started
enabled: true