---
- name: SFTPGo Playbook (K8s)
  hosts: sftpgo
  gather_facts: true

# Specific tasks for this playbook
  tasks:
    - name: Set required facts
      ansible.builtin.set_fact:
        sftpgo_home: "{{ persistent_data | default('/var/lib') }}/sftpgo"
        sftpgo_mysql_home: "{{ database_path | default('/var/lib') }}/mysql.sftpgo"
        sftpgo_user_id: 1000
        sftpgo_group_id: 1000
        mysql_user_id: 999
        mysql_group_id: 107
      tags: always

    - name: Create required sftpgo data folder
      become: true
      ansible.builtin.file:
        state: directory
        path: "{{ sftpgo_home }}"
        mode: "0750"
        owner: "{{ sftpgo_user_id }}"
        group: "{{ sftpgo_group_id }}"
      tags:
        - tasks
        - tasks::folders

    - name: Create required mysql data folder
      become: true
      ansible.builtin.file:
        state: directory
        path: "{{ sftpgo_mysql_home }}"
        mode: "0755"
        owner: "{{ mysql_user_id }}"
        group: "{{ mysql_group_id }}"
      tags:
        - tasks
        - tasks::folders
