Skip to content

Commit

Permalink
Alternatrr: Convert to multi instance, deprecate AlternatrrX
Browse files Browse the repository at this point in the history
  • Loading branch information
owine committed Sep 18, 2023
1 parent 1f005e8 commit c115f3b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 69 deletions.
2 changes: 0 additions & 2 deletions defaults/settings.yml.default
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
alternatrrx:
roles: ["1080webdl", "1080remux"]
a_train:
remotes: [""]
delugevpn:
Expand Down
68 changes: 40 additions & 28 deletions roles/alternatrr/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
# Basics
################################

alternatrr_name: alternatrr
alternatrr_instances: ["alternatrr"]

################################
# Settings
################################

alternatrr_sonarr_instance: "{{ sonarr_name }}"

################################
# Paths
Expand All @@ -30,16 +36,16 @@ alternatrr_paths_folders_list:
alternatrr_web_subdomain: "{{ alternatrr_name }}"
alternatrr_web_domain: "{{ user.domain }}"
alternatrr_web_port: "80"
alternatrr_web_url: "{{ 'https://' + (alternatrr_web_subdomain + '.' + alternatrr_web_domain
if (alternatrr_web_subdomain | length > 0)
else alternatrr_web_domain) }}"
alternatrr_web_url: "{{ 'https://' + (lookup('vars', alternatrr_name + '_web_subdomain', default=alternatrr_web_subdomain) + '.' + lookup('vars', alternatrr_name + '_web_domain', default=alternatrr_web_domain)
if (lookup('vars', alternatrr_name + '_web_subdomain', default=alternatrr_web_subdomain) | length > 0)
else lookup('vars', alternatrr_name + '_web_domain', default=alternatrr_web_domain)) }}"

################################
# DNS
################################

alternatrr_dns_record: "{{ alternatrr_web_subdomain }}"
alternatrr_dns_zone: "{{ alternatrr_web_domain }}"
alternatrr_dns_record: "{{ lookup('vars', alternatrr_name + '_web_subdomain', default=alternatrr_web_subdomain) }}"
alternatrr_dns_zone: "{{ lookup('vars', alternatrr_name + '_web_domain', default=alternatrr_web_domain) }}"
alternatrr_dns_proxy: "{{ dns.proxied }}"

################################
Expand All @@ -61,14 +67,16 @@ alternatrr_docker_container: "{{ alternatrr_name }}"

# Image
alternatrr_docker_image_pull: true
alternatrr_docker_image_repo: "theultimatecoder/alternatrr"
alternatrr_docker_image_tag: "latest"
alternatrr_docker_image: "theultimatecoder/alternatrr:{{ alternatrr_docker_image_tag }}"
alternatrr_docker_image: "{{ lookup('vars', alternatrr_name + '_docker_image_repo', default=alternatrr_docker_image_repo)
+ ':' + lookup('vars', alternatrr_name + '_docker_image_tag', default=alternatrr_docker_image_tag) }}"

# Ports
alternatrr_docker_ports_defaults: []
alternatrr_docker_ports_custom: []
alternatrr_docker_ports: "{{ alternatrr_docker_ports_defaults
+ alternatrr_docker_ports_custom }}"
alternatrr_docker_ports: "{{ lookup('vars', alternatrr_name + '_docker_ports_defaults', default=alternatrr_docker_ports_defaults)
+ lookup('vars', alternatrr_name + '_docker_ports_custom', default=alternatrr_docker_ports_custom) }}"

# Envs
alternatrr_docker_envs_default:
Expand All @@ -77,65 +85,69 @@ alternatrr_docker_envs_default:
Login__Username: "{{ user.name }}"
Login__Password: "{{ user.pass }}"
alternatrr_docker_envs_custom: {}
alternatrr_docker_envs: "{{ alternatrr_docker_envs_default
| combine(alternatrr_docker_envs_custom) }}"
alternatrr_docker_envs: "{{ lookup('vars', alternatrr_name + '_docker_envs_default', default=alternatrr_docker_envs_default)
| combine(lookup('vars', alternatrr_name + '_docker_envs_custom', default=alternatrr_docker_envs_custom)) }}"

# Commands
alternatrr_docker_commands_default: []
alternatrr_docker_commands_custom: []
alternatrr_docker_commands: "{{ alternatrr_docker_commands_default
+ alternatrr_docker_commands_custom }}"
alternatrr_docker_commands: "{{ lookup('vars', alternatrr_name + '_docker_commands_default', default=alternatrr_docker_commands_default)
+ lookup('vars', alternatrr_name + '_docker_commands_custom', default=alternatrr_docker_commands_custom) }}"

# Volumes
alternatrr_docker_volumes_default:
- "{{ alternatrr_paths_location }}/app:/opt/alternatrr/app"
- "{{ sonarr_paths_location }}:/opt/sonarr"
- "{{ server_appdata_path + lookup('vars', alternatrr_name + '_sonarr_instance', default=alternatrr_sonarr_instance) }}:/opt/sonarr"
alternatrr_docker_volumes_custom: []
alternatrr_docker_volumes: "{{ alternatrr_docker_volumes_default
+ alternatrr_docker_volumes_custom }}"
alternatrr_docker_volumes: "{{ lookup('vars', alternatrr_name + '_docker_volumes_default', default=alternatrr_docker_volumes_default)
+ lookup('vars', alternatrr_name + '_docker_volumes_custom', default=alternatrr_docker_volumes_custom) }}"

# Devices
alternatrr_docker_devices_default: []
alternatrr_docker_devices_custom: []
alternatrr_docker_devices: "{{ alternatrr_docker_devices_default
+ alternatrr_docker_devices_custom }}"
alternatrr_docker_devices: "{{ lookup('vars', alternatrr_name + '_docker_devices_default', default=alternatrr_docker_devices_default)
+ lookup('vars', alternatrr_name + '_docker_devices_custom', default=alternatrr_docker_devices_custom) }}"

# Hosts
alternatrr_docker_hosts_default: []
alternatrr_docker_hosts_custom: []
alternatrr_docker_hosts: "{{ docker_hosts_common
| combine(alternatrr_docker_hosts_default)
| combine(alternatrr_docker_hosts_custom) }}"
| combine(lookup('vars', alternatrr_name + '_docker_hosts_default', default=alternatrr_docker_hosts_default))
| combine(lookup('vars', alternatrr_name + '_docker_hosts_custom', default=alternatrr_docker_hosts_custom)) }}"

# Labels
alternatrr_docker_labels_default: {}
alternatrr_docker_labels_custom: {}
alternatrr_docker_labels: "{{ docker_labels_common
| combine(alternatrr_docker_labels_default)
| combine(alternatrr_docker_labels_custom) }}"
| combine(lookup('vars', alternatrr_name + '_docker_labels_default', default=alternatrr_docker_labels_default))
| combine(lookup('vars', alternatrr_name + '_docker_labels_custom', default=alternatrr_docker_labels_custom)) }}"

# Hostname
alternatrr_docker_hostname: "{{ alternatrr_name }}"

# Network Mode
alternatrr_docker_network_mode_default: "{{ docker_networks_name_common }}"
alternatrr_docker_network_mode: "{{ lookup('vars', alternatrr_name + '_docker_network_mode_default', default=alternatrr_docker_network_mode_default) }}"

# Networks
alternatrr_docker_networks_alias: "{{ alternatrr_name }}"
alternatrr_docker_networks_default: []
alternatrr_docker_networks_custom: []
alternatrr_docker_networks: "{{ docker_networks_common
+ alternatrr_docker_networks_default
+ alternatrr_docker_networks_custom }}"
+ lookup('vars', alternatrr_name + '_docker_networks_default', default=alternatrr_docker_networks_default)
+ lookup('vars', alternatrr_name + '_docker_networks_custom', default=alternatrr_docker_networks_custom) }}"

# Capabilities
alternatrr_docker_capabilities_default: []
alternatrr_docker_capabilities_custom: []
alternatrr_docker_capabilities: "{{ alternatrr_docker_capabilities_default
+ alternatrr_docker_capabilities_custom }}"
alternatrr_docker_capabilities: "{{ lookup('vars', alternatrr_name + '_docker_capabilities_default', default=alternatrr_docker_capabilities_default)
+ lookup('vars', alternatrr_name + '_docker_capabilities_custom', default=alternatrr_docker_capabilities_custom) }}"

# Security Opts
alternatrr_docker_security_opts_default: []
alternatrr_docker_security_opts_custom: []
alternatrr_docker_security_opts: "{{ alternatrr_docker_security_opts_default
+ alternatrr_docker_security_opts_custom }}"
alternatrr_docker_security_opts: "{{ lookup('vars', alternatrr_name + '_docker_security_opts_default', default=alternatrr_docker_security_opts_default)
+ lookup('vars', alternatrr_name + '_docker_security_opts_custom', default=alternatrr_docker_security_opts_custom) }}"

# Restart Policy
alternatrr_docker_restart_policy: unless-stopped
Expand Down
25 changes: 6 additions & 19 deletions roles/alternatrr/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,10 @@
# GNU General Public License v3.0 #
#########################################################################
---
- name: Set Default Sonarr instance
ansible.builtin.set_fact:
sonarr_name: "{{ sonarr_instances[0] }}"
when: not sonarr_name is defined

- name: Add DNS record
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/dns/tasker.yml"
- name: "Execute Alternatrr roles"
ansible.builtin.include_tasks: main2.yml
vars:
dns_record: "{{ lookup('vars', role_name + '_dns_record') }}"
dns_zone: "{{ lookup('vars', role_name + '_dns_zone') }}"
dns_proxy: "{{ lookup('vars', role_name + '_dns_proxy') }}"

- name: Remove existing Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/remove_docker_container.yml"

- name: Create directories
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/directories/create_directories.yml"

- name: Create Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"
alternatrr_name: "{{ role }}"
with_items: "{{ alternatrr_instances }}"
loop_control:
loop_var: role
29 changes: 29 additions & 0 deletions roles/alternatrr/tasks/main2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#########################################################################
# Title: Sandbox: alternatrr #
# Author(s): TheUltimateC0der, salty #
# URL: https://github.com/saltyorg/Sandbox #
# -- #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Set Default Sonarr instance
ansible.builtin.set_fact:
sonarr_name: "{{ sonarr_instances[0] }}"
when: not sonarr_name is defined

- name: Add DNS record
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/dns/tasker.yml"
vars:
dns_record: "{{ lookup('vars', role_name + '_dns_record') }}"
dns_zone: "{{ lookup('vars', role_name + '_dns_zone') }}"
dns_proxy: "{{ lookup('vars', role_name + '_dns_proxy') }}"

- name: Remove existing Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/remove_docker_container.yml"

- name: Create directories
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/directories/create_directories.yml"

- name: Create Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"
18 changes: 0 additions & 18 deletions roles/alternatrrx/tasks/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- { role: airsonic, tags: ['airsonic'] }
- { role: alltube, tags: ['alltube'] }
- { role: alternatrr, tags: ['alternatrr'] }
- { role: alternatrrx, tags: ['alternatrrx'] }
- { role: apprise, tags: ['apprise'] }
- { role: archivebox, tags: ['archivebox'] }
- { role: aria2_ng, tags: ['aria2-ng'] }
Expand Down Expand Up @@ -159,7 +158,6 @@
- { role: traefik_robotstxt, tags: ['traefik-robotstxt'] }
- { role: transmission, tags: ['transmission'] }
- { role: transmissionvpn, tags: ['transmissionvpn'] }
- { role: transmissionx, tags: ['transmissionx'] }
- { role: trilium, tags: ['trilium'] }
- { role: tubearchivist, tags: ['tubearchivist'] }
- { role: tvheadend, tags: ['tvheadend'] }
Expand Down

0 comments on commit c115f3b

Please sign in to comment.