diff --git a/nas.yml b/nas.yml index bfb1e345..8a47f28e 100644 --- a/nas.yml +++ b/nas.yml @@ -80,37 +80,30 @@ - role: dashy tags: - dashy - when: (dashy_enabled | default(False)) - role: deluge tags: - deluge - when: (deluge_enabled | default(False)) - role: dokuwiki tags: - dokuwiki - when: (dokuwiki_enabled | default(False)) - role: duplicacy tags: - duplicacy - when: (duplicacy_enabled | default(False)) - role: duplicati tags: - duplicati - when: (duplicati_enabled | default(False)) - role: emby tags: - emby - when: (emby_enabled | default(False)) - role: esphome tags: - esphome - when: (esphome_enabled | default(False)) - role: firefly tags: diff --git a/roles/dashy/defaults/main.yml b/roles/dashy/defaults/main.yml index cfcc9dd3..1a7edc11 100644 --- a/roles/dashy/defaults/main.yml +++ b/roles/dashy/defaults/main.yml @@ -8,3 +8,6 @@ dashy_hostname: "dashy" # specs dashy_memory: 2g + +# docker +dashy_container_name: dashy diff --git a/roles/dashy/tasks/main.yml b/roles/dashy/tasks/main.yml index 1d2786d2..2e6605ce 100644 --- a/roles/dashy/tasks/main.yml +++ b/roles/dashy/tasks/main.yml @@ -1,17 +1,28 @@ --- -- name: Dashy Docker Container - docker_container: - name: dashy - image: lissy93/dashy:latest - pull: true - ports: - - "{{ dashy_port }}:80" - restart_policy: unless-stopped - memory: "{{ dashy_memory }}" - labels: - traefik.enable: "{{ dashy_available_externally | string }}" - traefik.http.routers.dashy.rule: "Host(`{{ dashy_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.dashy.tls.certresolver: "letsencrypt" - traefik.http.routers.dashy.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.dashy.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.dashy.loadbalancer.server.port: "80" +- name: Start Dashy + block: + - name: Dashy Docker Container + docker_container: + name: "{{ dashy_container_name }}" + image: lissy93/dashy:latest + pull: true + ports: + - "{{ dashy_port }}:80" + restart_policy: unless-stopped + memory: "{{ dashy_memory }}" + labels: + traefik.enable: "{{ dashy_available_externally | string }}" + traefik.http.routers.dashy.rule: "Host(`{{ dashy_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.dashy.tls.certresolver: "letsencrypt" + traefik.http.routers.dashy.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.dashy.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.dashy.loadbalancer.server.port: "80" + when: dashy_enabled is true + +- name: Stop Dashy + block: + - name: Stop Dashy + docker_container: + name: "{{ dashy_container_name }}" + state: absent + when: dashy_enabled is false diff --git a/roles/deluge/defaults/main.yml b/roles/deluge/defaults/main.yml index f86f4151..e6c588d1 100644 --- a/roles/deluge/defaults/main.yml +++ b/roles/deluge/defaults/main.yml @@ -22,3 +22,5 @@ deluge_timezone: "{{ ansible_nas_timezone }}" # specs deluge_memory: 1g + +deluge_container_name: deluge diff --git a/roles/deluge/tasks/main.yml b/roles/deluge/tasks/main.yml index b482e5bb..78c0cb7f 100644 --- a/roles/deluge/tasks/main.yml +++ b/roles/deluge/tasks/main.yml @@ -1,33 +1,43 @@ --- -- name: Create Deluge Directories - file: - path: "{{ item }}" - state: directory - # mode: 0755 - with_items: - - "{{ deluge_config_directory }}" - - "{{ deluge_download_directory }}" +- name: Start Deluge + block: + - name: Create Deluge Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ deluge_config_directory }}" + - "{{ deluge_download_directory }}" -- name: Deluge Docker Container - docker_container: - name: deluge - image: linuxserver/deluge - pull: true - volumes: - - "{{ deluge_config_directory }}:/config:rw" - - "{{ deluge_download_directory }}:/root/Downloads:rw" - ports: - - "{{ deluge_port }}:8112" - env: - TZ: "{{ deluge_timezone }}" - PUID: "{{ deluge_user_id }}" - PGID: "{{ deluge_group_id }}" - restart_policy: unless-stopped - memory: "{{ deluge_memory }}" - labels: - traefik.enable: "{{ deluge_available_externally | string }}" - traefik.http.routers.deluge.rule: "Host(`{{ deluge_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.deluge.tls.certresolver: "letsencrypt" - traefik.http.routers.deluge.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.deluge.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.deluge.loadbalancer.server.port: "8112" + - name: Deluge Docker Container + docker_container: + name: deluge + image: linuxserver/deluge + pull: true + volumes: + - "{{ deluge_config_directory }}:/config:rw" + - "{{ deluge_download_directory }}:/root/Downloads:rw" + ports: + - "{{ deluge_port }}:8112" + env: + TZ: "{{ deluge_timezone }}" + PUID: "{{ deluge_user_id }}" + PGID: "{{ deluge_group_id }}" + restart_policy: unless-stopped + memory: "{{ deluge_memory }}" + labels: + traefik.enable: "{{ deluge_available_externally | string }}" + traefik.http.routers.deluge.rule: "Host(`{{ deluge_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.deluge.tls.certresolver: "letsencrypt" + traefik.http.routers.deluge.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.deluge.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.deluge.loadbalancer.server.port: "8112" + when: when deluge_enabled is true + +- name: Stop Deluge + block: + - name: Stop Deluge + docker_container: + name: "{{ deluge_container_name }}" + state: absent + when: deluge_enabled is false diff --git a/roles/dokuwiki/defaults/main.yml b/roles/dokuwiki/defaults/main.yml index 6f355336..90198228 100644 --- a/roles/dokuwiki/defaults/main.yml +++ b/roles/dokuwiki/defaults/main.yml @@ -15,3 +15,6 @@ dokuwiki_port: "8085" # specs dokuwiki_memory: 1g + +# docker +docuwiki_container_name: docuwiki diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml index a39a9ea9..4f47df6c 100644 --- a/roles/dokuwiki/tasks/main.yml +++ b/roles/dokuwiki/tasks/main.yml @@ -1,30 +1,41 @@ --- -- name: Create DokuWiki Directories - file: - path: "{{ item }}" - state: directory - with_items: - - "{{ dokuwiki_data_directory }}/data" +- name: Start Docuwiki + block: + - name: Create DokuWiki Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ dokuwiki_data_directory }}/data" -- name: DokuWiki Docker Container - docker_container: - name: dokuwiki - image: linuxserver/dokuwiki:latest - pull: true - volumes: - - "{{ dokuwiki_data_directory }}:/config/dokuwiki/data:rw" - ports: - - "{{ dokuwiki_port }}:80" - env: - TZ: "{{ ansible_nas_timezone }}" - PUID: "{{ dokuwiki_user_id }}" - PGID: "{{ dokuwiki_group_id }}" - restart_policy: unless-stopped - memory: "{{ dokuwiki_memory }}" - labels: - traefik.enable: "{{ dokuwiki_available_externally | string }}" - traefik.http.routers.dokuwiki.rule: "Host(`{{ dokuwiki_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.dokuwiki.tls.certresolver: "letsencrypt" - traefik.http.routers.dokuwiki.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.dokuwiki.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.dokuwiki.loadbalancer.server.port: "80" + - name: DokuWiki Docker Container + docker_container: + name: "{{ docuwiki_container_name }}" + image: linuxserver/dokuwiki:latest + pull: true + volumes: + - "{{ dokuwiki_data_directory }}:/config/dokuwiki/data:rw" + ports: + - "{{ dokuwiki_port }}:80" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ dokuwiki_user_id }}" + PGID: "{{ dokuwiki_group_id }}" + restart_policy: unless-stopped + memory: "{{ dokuwiki_memory }}" + labels: + traefik.enable: "{{ dokuwiki_available_externally | string }}" + traefik.http.routers.dokuwiki.rule: "Host(`{{ dokuwiki_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.dokuwiki.tls.certresolver: "letsencrypt" + traefik.http.routers.dokuwiki.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.dokuwiki.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.dokuwiki.loadbalancer.server.port: "80" + when: docuwiki_enabled is true + +- name: Stop Docuwiki + block: + - name: Stop Docuwiki + docker_container: + name: "{{ docuwiki_container_name }}" + state: absent + when: docuwiki_enabled is false diff --git a/roles/duplicacy/defaults/main.yml b/roles/duplicacy/defaults/main.yml index b1ad2ae8..e5ca8713 100644 --- a/roles/duplicacy/defaults/main.yml +++ b/roles/duplicacy/defaults/main.yml @@ -22,3 +22,6 @@ duplicacy_port: "3875" duplicacy_hostname: "duplicacy" duplicacy_memory: 1g + +# docker +duplicacy_container_name: duplicacy diff --git a/roles/duplicacy/tasks/main.yml b/roles/duplicacy/tasks/main.yml index cd9fc15d..832b2315 100644 --- a/roles/duplicacy/tasks/main.yml +++ b/roles/duplicacy/tasks/main.yml @@ -1,37 +1,48 @@ --- -- name: Create Duplicacy Directories - file: - path: "{{ item }}" - state: directory - with_items: - - "{{ duplicacy_config_directory }}" - - "{{ duplicacy_logs_directory }}" - - "{{ duplicacy_cache_directory }}" +- name: Start Duplicacy + block: + - name: Create Duplicacy Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ duplicacy_config_directory }}" + - "{{ duplicacy_logs_directory }}" + - "{{ duplicacy_cache_directory }}" -- name: Duplicacy Docker Container - docker_container: - name: duplicacy - image: saspus/duplicacy-web:mini - hostname: "{{ duplicacy_hostname }}" - pull: true - ports: - - "{{ duplicacy_port }}:3875" - volumes: - - "{{ duplicacy_config_directory }}:/config:rw" - - "{{ duplicacy_logs_directory }}:/logs:rw" - - "{{ duplicacy_cache_directory }}:/cache:rw" - - "{{ samba_shares_root }}:/backuproot:{{ duplicacy_data_permissions }}" - env: - DUPLICACY_WEB_VERSION: "{{ duplicacy_web_version }}" - TZ: "{{ ansible_nas_timezone }}" - USR_ID: "{{ duplicacy_user_id }}" - GRP_ID: "{{ duplicacy_group_id }}" - restart_policy: unless-stopped - memory: "{{ duplicacy_memory }}" - labels: - traefik.enable: "{{ duplicacy_available_externally | string }}" - traefik.http.routers.duplicacy.rule: "Host(`{{ duplicacy_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.duplicacy.tls.certresolver: "letsencrypt" - traefik.http.routers.duplicacy.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.duplicacy.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.duplicacy.loadbalancer.server.port: "3875" + - name: Duplicacy Docker Container + docker_container: + name: "{{ duplicacy_container_name }}" + image: saspus/duplicacy-web:mini + hostname: "{{ duplicacy_hostname }}" + pull: true + ports: + - "{{ duplicacy_port }}:3875" + volumes: + - "{{ duplicacy_config_directory }}:/config:rw" + - "{{ duplicacy_logs_directory }}:/logs:rw" + - "{{ duplicacy_cache_directory }}:/cache:rw" + - "{{ samba_shares_root }}:/backuproot:{{ duplicacy_data_permissions }}" + env: + DUPLICACY_WEB_VERSION: "{{ duplicacy_web_version }}" + TZ: "{{ ansible_nas_timezone }}" + USR_ID: "{{ duplicacy_user_id }}" + GRP_ID: "{{ duplicacy_group_id }}" + restart_policy: unless-stopped + memory: "{{ duplicacy_memory }}" + labels: + traefik.enable: "{{ duplicacy_available_externally | string }}" + traefik.http.routers.duplicacy.rule: "Host(`{{ duplicacy_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.duplicacy.tls.certresolver: "letsencrypt" + traefik.http.routers.duplicacy.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.duplicacy.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.duplicacy.loadbalancer.server.port: "3875" + when: duplicacy_enabled is true + +- name: Stop Duplicacy + block: + - name: Stop Duplicacy + docker_container: + name: "{{ duplicacy_container_name }}" + state: absent + when: duplicacy_enabled is false diff --git a/roles/duplicati/defaults/main.yml b/roles/duplicati/defaults/main.yml index 285100b7..555523c5 100644 --- a/roles/duplicati/defaults/main.yml +++ b/roles/duplicati/defaults/main.yml @@ -17,3 +17,6 @@ duplicati_port: "8200" duplicati_hostname: "duplicati" duplicati_memory: 1g + +# docker +duplicati_container_name: duplicati diff --git a/roles/duplicati/tasks/main.yml b/roles/duplicati/tasks/main.yml index 291fe15e..4794f2e5 100644 --- a/roles/duplicati/tasks/main.yml +++ b/roles/duplicati/tasks/main.yml @@ -1,33 +1,44 @@ --- -- name: Create Duplicati Directory - file: - path: "{{ item }}" - state: directory - with_items: - - "{{ duplicati_data_directory }}" +- name: Start Duplicati + block: + - name: Create Duplicati Directory + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ duplicati_data_directory }}" -- name: Dupicati Docker Container - docker_container: - name: duplicati - image: linuxserver/duplicati - pull: true - ports: - - "{{ duplicati_port }}:8200" - volumes: - - "{{ duplicati_data_directory }}:/config:rw" - - "{{ samba_shares_root }}:/source/shares:{{ duplicati_data_permissions }}" - - "{{ docker_home }}:/source/docker:{{ duplicati_data_permissions }}" - - "/etc/timezone:/etc/timezone:ro" - env: - TZ: "{{ ansible_nas_timezone }}" - PUID: "{{ duplicati_user_id }}" - PGID: "{{ duplicati_group_id }}" - restart_policy: unless-stopped - memory: "{{ duplicati_memory }}" - labels: - traefik.enable: "{{ duplicati_available_externally | string }}" - traefik.http.routers.duplicati.rule: "Host(`{{ duplicati_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.duplicati.tls.certresolver: "letsencrypt" - traefik.http.routers.duplicati.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.duplicati.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.duplicati.loadbalancer.server.port: "8200" + - name: Dupicati Docker Container + docker_container: + name: "{{ duplicati_container_name }}" + image: linuxserver/duplicati + pull: true + ports: + - "{{ duplicati_port }}:8200" + volumes: + - "{{ duplicati_data_directory }}:/config:rw" + - "{{ samba_shares_root }}:/source/shares:{{ duplicati_data_permissions }}" + - "{{ docker_home }}:/source/docker:{{ duplicati_data_permissions }}" + - "/etc/timezone:/etc/timezone:ro" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ duplicati_user_id }}" + PGID: "{{ duplicati_group_id }}" + restart_policy: unless-stopped + memory: "{{ duplicati_memory }}" + labels: + traefik.enable: "{{ duplicati_available_externally | string }}" + traefik.http.routers.duplicati.rule: "Host(`{{ duplicati_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.duplicati.tls.certresolver: "letsencrypt" + traefik.http.routers.duplicati.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.duplicati.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.duplicati.loadbalancer.server.port: "8200" + when: duplicati_enabled is true + +- name: Stop Duplicati + block: + - name: Stop Duplicati + docker_container: + name: "{{ duplicati_container_name }}" + state: absent + when: duplicati_enabled is false diff --git a/roles/emby/defaults/main.yml b/roles/emby/defaults/main.yml index 4954b6b8..72121a9a 100644 --- a/roles/emby/defaults/main.yml +++ b/roles/emby/defaults/main.yml @@ -23,3 +23,6 @@ emby_hostname: "emby" # specs emby_memory: 1g + +# docker +emby_container_name: emby diff --git a/roles/emby/tasks/main.yml b/roles/emby/tasks/main.yml index 7aff7bf5..f7afc681 100644 --- a/roles/emby/tasks/main.yml +++ b/roles/emby/tasks/main.yml @@ -1,33 +1,44 @@ --- -- name: Create Emby Directories - file: - path: "{{ item }}" - state: directory - with_items: - - "{{ emby_config_directory }}" +- name: Start Emby + block: + - name: Create Emby Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ emby_config_directory }}" -- name: Emby Docker Container - docker_container: - name: emby - image: emby/embyserver - pull: true - volumes: - - "{{ emby_config_directory }}:/config:rw" - - "{{ emby_movies_directory }}:/movies:{{ emby_movies_permissions }}" - - "{{ emby_tv_directory }}:/tv:{{ emby_tv_permissions }}" - ports: - - "{{ emby_port_http }}:8096" - - "{{ emby_port_https }}:8920" - env: - TZ: "{{ ansible_nas_timezone }}" - PUID: "{{ emby_user_id }}" - PGID: "{{ emby_group_id }}" - restart_policy: unless-stopped - memory: "{{ emby_memory }}" - labels: - traefik.enable: "{{ emby_available_externally | string }}" - traefik.http.routers.emby.rule: "Host(`{{ emby_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.emby.tls.certresolver: "letsencrypt" - traefik.http.routers.emby.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.emby.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.emby.loadbalancer.server.port: "8096" + - name: Emby Docker Container + docker_container: + name: "{{ emby_container_name }}" + image: emby/embyserver + pull: true + volumes: + - "{{ emby_config_directory }}:/config:rw" + - "{{ emby_movies_directory }}:/movies:{{ emby_movies_permissions }}" + - "{{ emby_tv_directory }}:/tv:{{ emby_tv_permissions }}" + ports: + - "{{ emby_port_http }}:8096" + - "{{ emby_port_https }}:8920" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ emby_user_id }}" + PGID: "{{ emby_group_id }}" + restart_policy: unless-stopped + memory: "{{ emby_memory }}" + labels: + traefik.enable: "{{ emby_available_externally | string }}" + traefik.http.routers.emby.rule: "Host(`{{ emby_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.emby.tls.certresolver: "letsencrypt" + traefik.http.routers.emby.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.emby.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.emby.loadbalancer.server.port: "8096" + when: emby_enabled is true + +- name: Stop Emby + block: + - name: Stop Emby + docker_container: + name: "{{ emby_container_name }}" + state: absent + when: emby_enabled is false diff --git a/roles/esphome/defaults/main.yml b/roles/esphome/defaults/main.yml index c407a2b5..5269369a 100644 --- a/roles/esphome/defaults/main.yml +++ b/roles/esphome/defaults/main.yml @@ -15,3 +15,6 @@ esphome_port: "6052" # specs esphome_memory: 1g + +# docker +esphome_container_name: esphome diff --git a/roles/esphome/tasks/main.yml b/roles/esphome/tasks/main.yml index 6d678fc7..37c8871e 100644 --- a/roles/esphome/tasks/main.yml +++ b/roles/esphome/tasks/main.yml @@ -1,31 +1,42 @@ --- -- name: Create EspHome Directories - file: - path: "{{ item }}" - state: directory - with_items: - - "{{ esphome_data_directory }}/data" +- name: Start EspHome + block: + - name: Create EspHome Directories + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ esphome_data_directory }}/data" -- name: EspHome Docker Container - docker_container: - name: esphome - image: esphome/esphome:latest - pull: true - volumes: - - "{{ esphome_data_directory }}:/config:rw" - - "/etc/localtime:/etc/localtime:ro" - ports: - - "{{ esphome_port }}:6052" - env: - TZ: "{{ ansible_nas_timezone }}" - PUID: "{{ esphome_user_id }}" - PGID: "{{ esphome_group_id }}" - restart_policy: unless-stopped - memory: "{{ esphome_memory }}" - labels: - traefik.enable: "{{ esphome_available_externally | string }}" - traefik.http.routers.esphome.rule: "Host(`{{ esphome_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.esphome.tls.certresolver: "letsencrypt" - traefik.http.routers.esphome.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.esphome.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.esphome.loadbalancer.server.port: "80" + - name: EspHome Docker Container + docker_container: + name: "{{ esphome_container_name }}" + image: esphome/esphome:latest + pull: true + volumes: + - "{{ esphome_data_directory }}:/config:rw" + - "/etc/localtime:/etc/localtime:ro" + ports: + - "{{ esphome_port }}:6052" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ esphome_user_id }}" + PGID: "{{ esphome_group_id }}" + restart_policy: unless-stopped + memory: "{{ esphome_memory }}" + labels: + traefik.enable: "{{ esphome_available_externally | string }}" + traefik.http.routers.esphome.rule: "Host(`{{ esphome_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.esphome.tls.certresolver: "letsencrypt" + traefik.http.routers.esphome.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.esphome.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.esphome.loadbalancer.server.port: "80" + when: esphome_enabled is true + +- name: Stop EspHome + block: + - name: Stop EspHome + docker_container: + name: "{{ esphome_container_name }}" + state: absent + when: esphome_enabled is false diff --git a/roles/heimdall/defaults/main.yml b/roles/heimdall/defaults/main.yml index bc4f1d4e..c1cc657c 100644 --- a/roles/heimdall/defaults/main.yml +++ b/roles/heimdall/defaults/main.yml @@ -1,5 +1,5 @@ --- -heimdall_enabled: true +heimdall_enabled: false heimdall_available_externally: false # directories @@ -17,3 +17,5 @@ heimdall_group_id: "1310" # specs heimdall_memory: 1g + +heimdall_container_name: heimdall diff --git a/roles/heimdall/tasks/main.yml b/roles/heimdall/tasks/main.yml index da2bd423..31d13391 100644 --- a/roles/heimdall/tasks/main.yml +++ b/roles/heimdall/tasks/main.yml @@ -1,49 +1,60 @@ --- -- name: Create Heimdall group - group: - name: heimdall - gid: "{{ heimdall_group_id }}" - state: present +- name: Start Heimdall + block: + - name: Create Heimdall group + group: + name: heimdall + gid: "{{ heimdall_group_id }}" + state: present -- name: Create Heimdall user - user: - name: heimdall - uid: "{{ heimdall_user_id }}" - state: present - system: yes - update_password: on_create - create_home: no - group: heimdall + - name: Create Heimdall user + user: + name: heimdall + uid: "{{ heimdall_user_id }}" + state: present + system: yes + update_password: on_create + create_home: no + group: heimdall -- name: Create Heimdall Directories - file: - path: "{{ item }}" - state: directory - owner: heimdall - group: heimdall - with_items: - - "{{ heimdall_data_directory }}" + - name: Create Heimdall Directories + file: + path: "{{ item }}" + state: directory + owner: heimdall + group: heimdall + with_items: + - "{{ heimdall_data_directory }}" -- name: Create Heimdall container - docker_container: - name: heimdall - image: "{{ heimdall_docker_image }}" - pull: true - volumes: - - "{{ heimdall_data_directory }}:/config:rw" - env: - PUID: "{{ heimdall_user_id }}" - PGID: "{{ heimdall_group_id }}" - TZ: "{{ ansible_nas_timezone }}" - ports: - - "{{ heimdall_port_http }}:80" - - "{{ heimdall_port_https }}:443" - restart_policy: unless-stopped - memory: "{{ heimdall_memory }}" - labels: - traefik.enable: "{{ heimdall_available_externally | string }}" - traefik.http.routers.heimdall.rule: "Host(`{{ heimdall_hostname }}.{{ ansible_nas_domain }}`)" - traefik.http.routers.heimdall.tls.certresolver: "letsencrypt" - traefik.http.routers.heimdall.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.heimdall.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.heimdall.loadbalancer.server.port: "80" + - name: Create Heimdall container + docker_container: + name: "{{ heimdall_container_name }}" + image: "{{ heimdall_docker_image }}" + pull: true + volumes: + - "{{ heimdall_data_directory }}:/config:rw" + env: + PUID: "{{ heimdall_user_id }}" + PGID: "{{ heimdall_group_id }}" + TZ: "{{ ansible_nas_timezone }}" + ports: + - "{{ heimdall_port_http }}:80" + - "{{ heimdall_port_https }}:443" + restart_policy: unless-stopped + memory: "{{ heimdall_memory }}" + labels: + traefik.enable: "{{ heimdall_available_externally | string }}" + traefik.http.routers.heimdall.rule: "Host(`{{ heimdall_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.heimdall.tls.certresolver: "letsencrypt" + traefik.http.routers.heimdall.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.heimdall.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.heimdall.loadbalancer.server.port: "80" + when: heimdall_enabled is true + +- name: Stop Heimdall + block: + - name: Stop Heimdall + docker_container: + name: "{{ heimdall_container_name }}" + state: absent + when: heimdall_enabled is false