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

- name: snapper | Install config for each target
  template:
    src: snapshot/snapper.j2
    dest: /etc/snapper/configs/{{ item.name }}
    mode: '600'
    owner: root
    group: root
  loop: '{{ snapper }}'

- name: snapper | Install main snapper config
  copy:
    content: |
      # List of snapper configurations.
      SNAPPER_CONFIGS="{{ snapper | map(attribute='name') | join(' ') }}"
    dest: /etc/snapper/snapper
    mode: '644'
    owner: root
    group: root
  notify:
    - Create snapshots btrfs subvolumes manually
