---
- name: Ensure data directories are present
  ansible.builtin.file:
    path: '{{ item }}'
    state: directory
    mode: '0755'
    owner: 'debian'
    group: 'debian'
  become: true
  loop:
    - '{{ baikal_specific_dir }}'
    - '{{ baikal_config_dir }}'

- name: Ensure Quadlet files are present
  ansible.builtin.template:
    src: "baikal.container.j2"
    dest: "/home/debian/.config/containers/systemd/baikal.container"
    mode: '0755'
    owner: 'debian'
    group: 'debian'
  notify: 'restart baikal'

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

# - name: Ensure backup script is present
#   ansible.builtin.copy:
#     src: 'baikal.backup.sh'
#     dest: '/etc/backups/baikal.backup.sh'
#     owner: 'root'
#     group: 'root'
#     mode: '0644'
