---
- name: Create base directory
  ansible.builtin.file:
    path: /opt/iklimco
    state: directory
    mode: '0755'

- name: Create db specific directories
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    mode: '0755'
  loop:
    - /opt/iklimco/db
    - /opt/iklimco/backup
  when: inventory_hostname in groups['db']

- name: Create db data directories (bind mounts for MongoDB and PostgreSQL)
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    owner: "999"
    group: "999"
    mode: '0700'
  loop:
    - /opt/iklimco/db/mongodb
    - /opt/iklimco/db/postgresql
  when: inventory_hostname in groups['db']

- name: Create service node directories
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    mode: '0755'
  loop:
    - /opt/iklimco/ssl
  when: inventory_hostname in groups['app']
