ansible-nas/roles/sonarr/tasks/main.yml
2023-03-10 22:00:37 +01:00

44 lines
1.6 KiB
YAML

---
- name: Start Sonarr
block:
- name: Create Sonarr Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ sonarr_data_directory }}"
- name: Sonarr
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ sonarr_container_name }}"
image: "{{ sonarr_image_name }}:{{ sonarr_image_version }}"
pull: true
volumes:
- "{{ sonarr_tv_directory }}:/tv:rw"
- "{{ sonarr_download_directory }}:/downloads:rw"
- "{{ sonarr_data_directory }}:/config:rw"
ports:
- "{{ sonarr_port }}:8989"
env:
TZ: "{{ ansible_nas_timezone }}"
PUID: "{{ sonarr_user_id }}"
PGID: "{{ sonarr_group_id }}"
restart_policy: unless-stopped
memory: "{{ sonarr_memory }}"
labels:
traefik.enable: "{{ sonarr_available_externally | string }}"
traefik.http.routers.sonarr.rule: "Host(`{{ sonarr_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.sonarr.tls.certresolver: "letsencrypt"
traefik.http.routers.sonarr.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.sonarr.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.sonarr.loadbalancer.server.port: "8989"
when: sonarr_enabled is true
- name: Stop Sonarr
block:
- name: Stop Sonarr
community.docker.docker_container:
name: "{{ sonarr_container_name }}"
state: absent
when: sonarr_enabled is false