- name: Directory structure — cloud-pc
  hosts: cloud-pc
  become: true
  vars:
    data_user: ada
    data_group: ada
  tasks:
    - name: Create base mount points
      ansible.builtin.file:
        path: "{{ item.path }}"
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"
      loop: "{{ storage_mounts | default([]) }}"

    - name: Mount base storage disks
      ansible.posix.mount:
        path: "{{ item.path }}"
        src: "{{ item.src }}"
        fstype: "{{ item.fstype }}"
        opts: "{{ item.opts | default('defaults,nofail') }}"
        state: mounted
      loop: "{{ storage_mounts | default([]) }}"

    - name: Create service data and config directories
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"
      loop:
        - /opt/data/postgres
        - /opt/data/nextcloud
        - /opt/data/gitea
        - /opt/data/gitea-runner
        - /opt/data/syncthing
        - /opt/data/zerotier
        - /opt/samba/media
        - /opt/samba/documents
        - /opt/samba/backups_win
        - /opt/configs
        - /opt/configs/nextcloud/app
        - /opt/configs/syncthing

    - name: Create /opt/services
      ansible.builtin.file:
        path: /opt/services
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"

    - name: Create backup directories (3TB)
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"
      loop:
        - /mnt/backup/restic/services
        - /mnt/backup/restic/samba
        - /mnt/backup/devices/proxmox
        - /mnt/backup/devices/ada-x1

- name: Directory structure — mini-pc
  hosts: mini-pc
  become: true
  vars:
    data_user: ada
    data_group: ada
  tasks:
    - name: Create service directories
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"
      loop:
        - /opt/services
        - /opt/data
        - /opt/configs
        - /opt/data/vaultwarden
        - /opt/data/adguard/work
        - /opt/data/caddy
        - /opt/data/gitea-runner
        - /opt/data/npm
        - /opt/data/uptime-kuma
        - /opt/data/zerotier
        - /opt/configs/adguard
        - /opt/configs/caddy
        - /opt/configs/caddy/lego
        - /opt/configs/npm/letsencrypt

- name: Directory structure — ru-vps
  hosts: ru-vps
  become: true
  vars:
    data_user: ada
    data_group: ada
  tasks:
    - name: Create service directories
      ansible.builtin.file:
        path: "{{ item }}"
        state: directory
        owner: "{{ data_user }}"
        group: "{{ data_group }}"
        mode: "0755"
      loop:
        - /opt/services
        - /opt/data
        - /opt/configs
        - /opt/data/caddy
        - /opt/data/gitea-runner
        - /opt/data/zerotier
        - /opt/configs/caddy
