summaryrefslogtreecommitdiffstats
path: root/roles/restic/tasks/main.yml
blob: 8640a52135b232be666e9884375281f068d4ad25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: "Check installed restic versions"
  ansible.builtin.command:
    cmd: "mise ls restic"
  register: restic_installed_versions
  changed_when: false

- name: "Install restic"
  ansible.builtin.command:
    cmd: "mise use --global restic@{{ restic_version }}"
  changed_when: true
  when: restic_version not in restic_installed_versions.stdout

# mise installs restic under whichever user ran this task's own home. When
# that's root (e.g. containers connected to as root), the binary ends up
# under /root, unreachable by other accounts (ex. backup user)
# This copies the binary to a system-wide location so that any user can use it.
- name: "Resolve installed restic path"
  ansible.builtin.command:
    cmd: "mise which restic"
  register: restic_bin_path
  changed_when: false

- name: "Expose restic system-wide"
  become: true
  ansible.builtin.copy:
    remote_src: true
    src: "{{ restic_bin_path.stdout }}"
    dest: "/usr/local/bin/restic"
    mode: "0755"
    owner: "root"
    group: "root"