diff --git a/defaults/main.yml b/defaults/main.yml index 5ebc377..660a701 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,51 @@ --- -# defaults file for arrs \ No newline at end of file +# defaults file for arrs + +# Common defaults +# +timezone: 'Europe/Brussels' +torrent_downloads_volume: '/mnt/download' +arrs_configuration_volume: '/mnt/config' +arrs_setup_path: '~/arrs' +arrs_uid: +arrs_gid: + +deluge_enabled: true +sonarr_enabled: true +lidarr_enabled: true +jackett_enabled: true + +# Deluge torrent +# +deluge_image_version: 'latest' +deluge_loglevel: 'warning' + +deluge_host_port: 6881 +deluge_admin_port: 8112 + +deluge_config_volume: '{{ arrs_configuration_volume }}/deluge' + +# Sonarr +# +sonarr_image_version: 'latest' +sonarr_host_port: 8989 + +sonarr_config_volume: '{{ arrs_configuration_volume }}/sonarr' +sonarr_series_volume: '/mnt/videos/Series' + +# Lidarr +lidarr_image_version: 'latest' +lidarr_host_port: 8686 + +lidarr_config_volume: '{{ arrs_configuration_volume }}/lidarr' +lidarr_music_upload_volume: '/mnt/music/Reference' +lidarr_music_volumes: + - {path: '/mnt/music/Sonos', alias: 'sonos' } + - {path: '/mnt/music/Audiophile', alias: 'audiophile' } + - {path: '/mnt/music/Raw', alias: 'raw' } + +# Jakett +jackett_image_version: 'latest' +jackett_auto_update: true +jackett_host_port: 9117 +jackett_config_volume: '{{ arrs_configuration_volume }}/jackett' diff --git a/meta/main.yml b/meta/main.yml index 1031f40..dd9bbe5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,7 +2,7 @@ galaxy_info: author: Laur Ivan namespace: laurivan role_name: arrs - description: Sonarr, Lidarr, Deluge and proxy via Docker + description: Sonarr, Lidarr, Deluge and Jackett via Docker license: MIT min_ansible_version: "2.4" @@ -29,7 +29,7 @@ galaxy_info: - sonarr - lidarr - deluge - - proxy + - jackett - media - grabber - docker diff --git a/molecule/default/cleanup.yml b/molecule/default/cleanup.yml index 791d746..4c3ec7c 100644 --- a/molecule/default/cleanup.yml +++ b/molecule/default/cleanup.yml @@ -5,7 +5,7 @@ tasks: - name: Check if the docker-compose file exists. ansible.builtin.stat: - path: "~/plausible/docker-compose.yml" + path: "~/arrs/docker-compose.yml" register: docker_compose_file - name: Remove docker-compose. diff --git a/molecule/default/create.yml b/molecule/default/create.yml deleted file mode 100644 index 09489e3..0000000 --- a/molecule/default/create.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - - # TODO: Developer must implement and populate 'server' variable - - - when: server.changed | default(false) | bool - block: - - name: Populate instance config dict - ansible.builtin.set_fact: - instance_conf_dict: { - 'instance': "{{ }}", - 'address': "{{ }}", - 'user': "{{ }}", - 'port': "{{ }}", - 'identity_file': "{{ }}", } - with_items: "{{ server.results }}" - register: instance_config_dict - - - name: Convert instance config dict to a list - ansible.builtin.set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - - - name: Dump instance config - ansible.builtin.copy: - content: | - # Molecule managed - - {{ instance_conf | to_json | from_json | to_yaml }} - dest: "{{ molecule_instance_config }}" - mode: 0600 diff --git a/tasks/main.yml b/tasks/main.yml index d102a74..719aae3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,38 @@ --- -# tasks file for arrs \ No newline at end of file +# tasks file for arrs +- name: Set up directories + ansible.builtin.file: + state: directory + path: "{{ item }}" + owner: "{{ ansible_effective_user_id }}" + group: "{{ ansible_effective_group_id }}" + mode: "0750" + with_items: + - "{{ deluge_config_volume }}" + - "{{ sonarr_config_volume }}" + - "{{ lidarr_config_volume }}" + - "{{ jackett_config_volume }}" + - "{{ arrs_setup_path }}" + tags: + - configuration + become: true + +- name: Write configuration files + ansible.builtin.template: + src: "{{ item }}.j2" + dest: "{{ arrs_setup_path }}/{{ item }}" + mode: '0640' + loop: + - "docker-compose.yml" + - "env.deluge.conf" + - "env.sonarr.conf" + - "env.lidarr.conf" + - "env.jackett.conf" + tags: + - configuration + +- name: Ensure all requested components are running. + community.docker.docker_compose: + project_src: "{{ arrs_setup_path }}" + build: false + become: false diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index e69de29..2c0dacc 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -0,0 +1,67 @@ +version: "3.3" +services: +{% if deluge_enabled %} + deluge: + image: "linuxserver/deluge:{{ deluge_image_version }}" + restart: always + env_file: + - {{ arrs_setup_path }}/env.deluge.conf + volumes: + - {{ deluge_config_volume }}:/config + - {{ torrent_downloads_volume }}:/downloads + ports: + - {{ deluge_admin_port }}:8112 + - {{ deluge_host_port }}:6881 + - {{ deluge_host_port }}:6881/udp + networks: + - arrs +{% endif %} +{% if sonarr_enabled %} + sonarr: + image: "lscr.io/linuxserver/sonarr:{{ sonarr_image_version }}" + restart: always + env_file: + - {{ arrs_setup_path }}/env.sonarr.conf + volumes: + - {{ sonarr_config_volume }}:/config + - {{ sonarr_series_volume }}:/tv + - {{ torrent_downloads_volume }}:/downloads + ports: + - {{ sonarr_host_port }}:8989 + networks: + - arrs +{% endif %} +{% if lidarr_enabled %} + lidarr: + image: "lscr.io/linuxserver/lidarr:{{ lidarr_image_version }}" + restart: always + env_file: + - {{ arrs_setup_path }}/env.sonarr.conf + volumes: + - {{ lidarr_config_volume }}:/config + - {{ torrent_downloads_volume }}:/downloads + ports: + - {{ lidarr_host_port }}:8686 + networks: + - arrs +{% endif %} +{% if jackett_enabled %} + jackett: + image: "lscr.io/linuxserver/jackett:{{ jackett_image_version }}" + restart: always + env_file: + - {{ arrs_setup_path }}/env.jackett.conf + volumes: + - {{ jackett_config_volume }}:/config + - {{ torrent_downloads_volume }}:/downloads +{% for item in lidarr_music_volumes %} + - {{ item.path }}:/music/{{ item.alias }} +{% endfor %} + ports: + - {{ jackett_host_port }}:9117 + networks: + - arrs +{% endif %} + +networks: + arrs: {} diff --git a/templates/env.deluge.conf.j2 b/templates/env.deluge.conf.j2 new file mode 100644 index 0000000..7e8b8c2 --- /dev/null +++ b/templates/env.deluge.conf.j2 @@ -0,0 +1,8 @@ +TZ={{ timezone }} +DELUGE_LOGLEVEL={{ deluge_loglevel }} +{% if arrs_uid %} +PUID={{ arrs_uid }} +{% endif %} +{% if arrs_gid %} +PUID={{ arrs_gid }} +{% endif %} \ No newline at end of file diff --git a/templates/env.jackett.conf.j2 b/templates/env.jackett.conf.j2 new file mode 100644 index 0000000..454b6d7 --- /dev/null +++ b/templates/env.jackett.conf.j2 @@ -0,0 +1,8 @@ +AUTO_UPDATE={{ jackett_auto_update }} +TZ={{ timezone }} +{% if arrs_uid %} +PUID={{ arrs_uid }} +{% endif %} +{% if arrs_gid %} +PUID={{ arrs_gid }} +{% endif %} \ No newline at end of file diff --git a/templates/env.lidarr.conf.j2 b/templates/env.lidarr.conf.j2 new file mode 100644 index 0000000..e442b6e --- /dev/null +++ b/templates/env.lidarr.conf.j2 @@ -0,0 +1,7 @@ +TZ={{ timezone }} +{% if arrs_uid %} +PUID={{ arrs_uid }} +{% endif %} +{% if arrs_gid %} +PUID={{ arrs_gid }} +{% endif %} \ No newline at end of file diff --git a/templates/env.sonarr.conf.j2 b/templates/env.sonarr.conf.j2 new file mode 100644 index 0000000..053277f --- /dev/null +++ b/templates/env.sonarr.conf.j2 @@ -0,0 +1,8 @@ +MONO_EXTERNAL_ENCODINGS=UTF-8 +TZ={{ timezone }} +{% if arrs_uid %} +PUID={{ arrs_uid }} +{% endif %} +{% if arrs_gid %} +PUID={{ arrs_gid }} +{% endif %}