---

# Create /opt/dockge
- name: Creating /opt/dockge
  file:
    path: /opt/dockge
    owner: "{{ superuser }}"
    group: "{{ supergroup }}"
    state: directory

# Create /opt/stacks
- name: Creating /opt/stacks
  file:
    path: /opt/stacks
    owner: "{{ superuser }}"
    group: "{{ supergroup }}"
    state: directory


# Create /opt/dockge
- name: Creating /opt/dockge
  file:
    path: /opt/dockge
    owner: "{{ superuser }}"
    group: "{{ supergroup }}"
    state: directory

# Create /opt/dockge/data
- name: Creating /opt/dockge/data
  file:
    path: /opt/dockge/data
    owner: "{{ superuser }}"
    group: "{{ supergroup }}"
    state: directory

# Copy Dockge docker compose file
- name: Copying Dockge compose.yml
  copy:
    src: compose.yml
    dest: /opt/dockge/compose.yml
    owner: "{{ superuser }}"
    group: "{{ supergroup }}"
    mode: '0644'

# Docker compose up
- name: Starting Dockge if not already running
  shell: "docker compose up -d"
  args:
    chdir: /opt/dockge
