---
# Setup base directories for Docker services
- name: Setup Docker directories
  hosts: "{{ target_host | default('all') }}"
  gather_facts: true

  tasks:
    - name: Create base docker directory
      ansible.builtin.file:
        path: "{{ docker_data_path }}"
        state: directory
        mode: '0755'
      become: "{{ ansible_become | default(false) }}"

    - name: Create common directories
      ansible.builtin.file:
        path: "{{ docker_data_path }}/{{ item }}"
        state: directory
        mode: '0755'
      loop:
        - configs
        - data
        - logs
        - backups
      become: "{{ ansible_become | default(false) }}"

    - name: Create service directories from host_services
      ansible.builtin.file:
        path: "{{ docker_data_path }}/{{ item.stack_dir }}"
        state: directory
        mode: '0755'
      loop: "{{ host_services | default([]) }}"
      when: host_services is defined
      become: "{{ ansible_become | default(false) }}"
