---
# file: roles/borgbackup/tasks/install.yml

- name: Apt Repository
  apt_repository:
    repo: 'ppa:costamagnagianfranco/borgbackup'
    state: present
    mode: 0644

- name: Install borgbackup
  apt:
    pkg: '{{ packages }}'
    state: present
    update_cache: yes
  vars:
    packages:
      - libssl-dev
      - libacl1-dev
      - libacl1
      - build-essential
      - python-setuptools
      - python3-dev
      - python3-pip
      - python3-msgpack
      - openssh-client
      - cron
      - borgbackup

- name: Install borgmatic
  pip:
    executable: pip3
    name: '{{ packages }}'
    state: latest
  vars:
    packages:
      - borgmatic

- name: Ensures directories
  file:
    path: '{{ item }}'
    state: directory
    mode: 0700
  with_items:
    - /var/backups/borg
    - /etc/borgmatic
    - /etc/borgmatic.d
