---
- name: Ensure subvolume permissions are correct
  ansible.builtin.file:
    path: "/mnt/data1/nefarious/{{ item.dir }}"
    state: directory
    mode: '0755'
    owner: "{{ item.owner }}"
    group: "{{ item.group }}"
  loop:
    - dir: 'nefarious'
      owner: 1000
      group: 1000

- name: Ensure configuration directory is present
  ansible.builtin.file:
    path: '/etc/nefarious'
    state: directory
    mode: '0755'

- name: Ensure Transmission config file is present
  ansible.builtin.copy:
    src: 'transmission-settings.json'
    dest: '/etc/nefarious/transmission-settings.json'
    owner: 'root'
    group: 'root'
    mode: '0644'

- name: Ensure Quadlet files is present
  ansible.builtin.template:
    src: "{{ item }}.j2"
    dest: "/home/debian/.config/containers/systemd/{{ item }}"
    mode: '0755'
    owner: 'debian'
    group: 'debian'
  loop:
    - 'nefarious-app.container'
    - 'nefarious-celery.container'
    - 'nefarious-jackett.container'
    - 'nefarious-transmission.container'

- name: Ensure Quadlet files is present
  ansible.builtin.copy:
    src: "{{ item }}"
    dest: "/home/debian/.config/containers/systemd/{{ item }}"
    mode: '0755'
    owner: 'debian'
    group: 'debian'
  loop:
    - 'nefarious-redis.container'
    - 'nefarious.pod'

- name: Ensure Caddyfile is present
  ansible.builtin.copy:
    src: 'nefarious.Caddyfile'
    dest: '/etc/caddy/nefarious.Caddyfile'
    owner: root
    group: root
    mode: '0644'
  # notify: reload caddy
