---

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - semaphore-db-1 
    - semaphore-app-1
  when: '"semaphore" in selected_containers'
   
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - authentik-postgresql-1
    - authentik-worker-1 
    - authentik-server-1 
    - authentik-redis-1 
  when: '"authentik" in selected_containers'
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - kestra-kestra-1
    - kestra-postgres-1 
  when: '"kestra" in selected_containers'
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - gitlab
  when: '"gitlab" in selected_containers'
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - nginx-app-1
  when: '"nginx" in selected_containers'
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - heimdall
  when: '"heimdall" in selected_containers'
- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - mailu3-admin-1
    - mailu3-antispam-1
    - mailu3-antivirus-1
    - mailu3-fetchmail-1
    - mailu3-front-1
    - mailu3-imap-1
    - mailu3-oletools-1
    - mailu3-redis-1
    - mailu3-resolver-1
    - mailu3-smtp-1
    - mailu3-webdav-1
    - mailu3-webmail-1
    - mailu3-fts_attachments-1
  when: '"mailu3" in selected_containers'

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - HomeAssistant
  when: '"homeassistant" in selected_containers'

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - webhub-web-1"
  when: '"webhub" in selected_containers'

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - mosquitto-mosquitto-1
  when: '"mosquitto" in selected_containers'

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - webhub-web-1
  when: '"webhub" in selected_containers'

- name: Add elements to a list
  set_fact:
    docker_containers: "{{ docker_containers | default([]) + [item] }}"
  loop:
    - pihole
  when: '"pihole" in selected_containers'

- debug:
    msg: "{{ docker_containers }}"
- name: Stop mailu containers 
  command: "docker stop {{ docker_containers|join(' ') }}"
  become: true
  ignore_errors: true
  