---

- name: Install fuse (to mount repositories)
  become: yes
  apt:
    name: fuse

- name: Install bzip2 (to install restic)
  become: yes
  apt:
    name: bzip2

- name: Install pigz (to compress db dumps)
  become: yes
  apt:
    name: pigz

- name: Download restic
  become: yes
  get_url:
    url: 'https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_linux_amd64.bz2'
    dest: '/tmp/restic_{{ restic_version }}_linux_amd64.bz2'

- name: Extract restic
  become: yes
  command: 'bzip2 -d /tmp/restic_{{ restic_version }}_linux_amd64.bz2'
  args:
    creates: '/tmp/restic_{{ restic_version }}_linux_amd64'

- name: Install restic
  become: yes
  copy:
    remote_src: true
    src: '/tmp/restic_{{ restic_version }}_linux_amd64'
    dest: "{{ restic_path }}"
    mode: 0755

- name: Remove downloaded file
  become: yes
  file:
    path: '/tmp/restic_{{ restic_version }}_linux_amd64'
    state: absent
