From dafd55e076cb54e03f53ccf0d23c0ab9e604e5ca Mon Sep 17 00:00:00 2001 From: David Stephens Date: Wed, 31 Aug 2022 00:29:40 +0100 Subject: [PATCH] Couchpotato start and stop --- roles/couchpotato/defaults/main.yml | 3 ++ roles/couchpotato/tasks/main.yml | 75 +++++++++++++++++------------ 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/roles/couchpotato/defaults/main.yml b/roles/couchpotato/defaults/main.yml index bc9a9023..53559957 100644 --- a/roles/couchpotato/defaults/main.yml +++ b/roles/couchpotato/defaults/main.yml @@ -17,3 +17,6 @@ couchpotato_port: "5050" # specs couchpotato_memory: 1g + +# docker +couchpotato_container_name: couchpotato diff --git a/roles/couchpotato/tasks/main.yml b/roles/couchpotato/tasks/main.yml index 0528147c..11366552 100644 --- a/roles/couchpotato/tasks/main.yml +++ b/roles/couchpotato/tasks/main.yml @@ -1,34 +1,45 @@ --- -- name: Create Couchpotato Directories - file: - path: "{{ item }}" - state: directory - # mode: 0755 - with_items: - - "{{ docker_home }}/couchpotato/config" +- name: Start Couchpotato + block: + - name: Create Couchpotato Directories + file: + path: "{{ item }}" + state: directory + # mode: 0755 + with_items: + - "{{ docker_home }}/couchpotato/config" -- name: Couchpotato Docker Container - docker_container: - name: couchpotato - image: linuxserver/couchpotato - pull: true - volumes: - - "{{ couchpotato_config_directory }}:/config:rw" - - "{{ couchpotato_downloads_directory }}:/downloads:rw" - - "{{ couchpotato_movies_directory }}:/movies:rw" - - "{{ couchpotato_torrents_directory }}:/torrents:rw" - ports: - - "{{ couchpotato_port }}:5050" - env: - TZ: "{{ ansible_nas_timezone }}" - PUID: "{{ couchpotato_user_id }}" - PGID: "{{ couchpotato_group_id }}" - restart_policy: unless-stopped - memory: "{{ couchpotato_memory }}" - labels: - traefik.enable: "{{ couchpotato_available_externally | string }}" - traefik.http.routers.couchpotato.rule: "Host(`couchpotato.{{ ansible_nas_domain }}`)" - traefik.http.routers.couchpotato.tls.certresolver: "letsencrypt" - traefik.http.routers.couchpotato.tls.domains[0].main: "{{ ansible_nas_domain }}" - traefik.http.routers.couchpotato.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" - traefik.http.services.couchpotato.loadbalancer.server.port: "5050" + - name: Couchpotato Docker Container + docker_container: + name: "{{ couchpotato_container_name }}" + image: linuxserver/couchpotato + pull: true + volumes: + - "{{ couchpotato_config_directory }}:/config:rw" + - "{{ couchpotato_downloads_directory }}:/downloads:rw" + - "{{ couchpotato_movies_directory }}:/movies:rw" + - "{{ couchpotato_torrents_directory }}:/torrents:rw" + ports: + - "{{ couchpotato_port }}:5050" + env: + TZ: "{{ ansible_nas_timezone }}" + PUID: "{{ couchpotato_user_id }}" + PGID: "{{ couchpotato_group_id }}" + restart_policy: unless-stopped + memory: "{{ couchpotato_memory }}" + labels: + traefik.enable: "{{ couchpotato_available_externally | string }}" + traefik.http.routers.couchpotato.rule: "Host(`couchpotato.{{ ansible_nas_domain }}`)" + traefik.http.routers.couchpotato.tls.certresolver: "letsencrypt" + traefik.http.routers.couchpotato.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.couchpotato.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.couchpotato.loadbalancer.server.port: "5050" + when: couchpotato_enabled is true + +- name: Stop Couchpotato + block: + - name: Stop Couchpotato + docker_container: + name: "{{ couchpotato_container_name }}" + state: absent + when: couchpotato_enabled is false