---
- name: btrbk | Install btrbk package
  community.general.apk:
    name: btrbk
    state: present

- name: btrbk | Copy config btrbk.conf
  template:
    src: snapshot/btrbk.conf.j2
    dest: /etc/btrbk/btrbk.conf
    mode: '644'
    owner: root
    group: root
  notify:
    - Create snapshots btrfs subvolumes manually

- name: btrbk | Create btrbk crontabs
  copy:
    content: |
      #!/bin/sh
      TZ=UTC exec /usr/bin/btrbk -q {{ item.value }}
    dest: /etc/periodic/{{ item.key }}/btrbk
    mode: '755'
    owner: root
    group: root
  loop: '{{ btrbk.cron | dict2items }}'
