Add sonarr
This commit is contained in:
@@ -33,6 +33,9 @@
|
|||||||
"immich": {
|
"immich": {
|
||||||
"database_pw": "ENC[AES256_GCM,data:SUyMGqu7deZyZpVt,iv:asZehOvn/JamwFyS+Xl9Xpr4JFkKlJjHVw7LywYOxTc=,tag:plRvuv7+ievfEhxurBl7YQ==,type:str]"
|
"database_pw": "ENC[AES256_GCM,data:SUyMGqu7deZyZpVt,iv:asZehOvn/JamwFyS+Xl9Xpr4JFkKlJjHVw7LywYOxTc=,tag:plRvuv7+ievfEhxurBl7YQ==,type:str]"
|
||||||
},
|
},
|
||||||
|
"sonarr": {
|
||||||
|
"database_pw": "ENC[AES256_GCM,data:TN381ZYJLeUHX9U3Jnd9+w==,iv:lKaMYHeaSGXJd0/EGxkDY2l2v62xG3xs8TVC0HwXL94=,tag:3z5rK+2RfJHJdQc7KC9KmA==,type:str]"
|
||||||
|
},
|
||||||
"sops": {
|
"sops": {
|
||||||
"age": [
|
"age": [
|
||||||
{
|
{
|
||||||
@@ -40,8 +43,8 @@
|
|||||||
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSByUWM4ZDVVbGFrUGdMRHBX\nUFBmU3Nlc0RBSzhFK0tHNHpkQXUvUVdiZUZJCmpRN1lFdENpWW0rcThjVlVQNUl6\nWnlLU0RnQ3FZby81Ly8xTFBrek9nMncKLS0tIFQ4UTRNOC9CRmx4OFJWem1wckZz\nUDFTSzdWZldFK3FqcTNWTWRyNDhHQ2MKS811mR5xn7qiC/aVgPFYJ5c6Q3zxRfcr\nHcvxUvB01vNJKZpRg92vvKPkV6lQO3DXCT98OdfwiymlEOvYxg71Pg==\n-----END AGE ENCRYPTED FILE-----\n"
|
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSByUWM4ZDVVbGFrUGdMRHBX\nUFBmU3Nlc0RBSzhFK0tHNHpkQXUvUVdiZUZJCmpRN1lFdENpWW0rcThjVlVQNUl6\nWnlLU0RnQ3FZby81Ly8xTFBrek9nMncKLS0tIFQ4UTRNOC9CRmx4OFJWem1wckZz\nUDFTSzdWZldFK3FqcTNWTWRyNDhHQ2MKS811mR5xn7qiC/aVgPFYJ5c6Q3zxRfcr\nHcvxUvB01vNJKZpRg92vvKPkV6lQO3DXCT98OdfwiymlEOvYxg71Pg==\n-----END AGE ENCRYPTED FILE-----\n"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"lastmodified": "2025-10-13T12:19:46Z",
|
"lastmodified": "2025-11-07T09:57:48Z",
|
||||||
"mac": "ENC[AES256_GCM,data:QJ1Prqf37xMZbvyMvjBVxZOiOr07CmCYrWmr+5hwDsEmG4eEC9sPF/UY+/Cy2OTzsMp+cHb6C3maAo09O171wj6nJIZucg3B9fjEW2+4AoO217G4vmauMl3FFkut2CuvVV9zt2B/fLAskRg/yeYYOhjzPkWA6lyeV31sV5ZQ6Kw=,iv:5WfkmNr5vdfTqp6+INjQN/Zmc7/iJNc/2auO9h3En08=,tag:snBgJyMzBXVAkV3zERkK8g==,type:str]",
|
"mac": "ENC[AES256_GCM,data:DPNWxb9zDNLZ5sIBgOvQ+Gky+F+B3MDA9pOcDkBlb7w7WhmOx1rAXzeK3FCbJDb/y6CQnTPHRQWAPo8bgikIrprmP3zxbSTRJVwKcgVj96KnpRCClVeRwOv7AuYOyxIF/xpUL98/SKciVZvcNh/gUqxt7vq3EsBw1yEAGORSKq0=,iv:Vzrpr19T39nVFHFMMcXivHacCgqS1X2+IcI311+er1I=,tag:ZwG0znMH3hoJ4o8WmOUm+g==,type:str]",
|
||||||
"encrypted_regex": "^(.*)$",
|
"encrypted_regex": "^(.*)$",
|
||||||
"version": "3.10.2"
|
"version": "3.10.2"
|
||||||
}
|
}
|
||||||
|
|||||||
118
2-nomad-config/sonarr.nomad.hcl
Normal file
118
2-nomad-config/sonarr.nomad.hcl
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
job "sonarr" {
|
||||||
|
group "sonarr" {
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
network {
|
||||||
|
mode = "bridge"
|
||||||
|
port "http" {
|
||||||
|
to = 8989
|
||||||
|
}
|
||||||
|
}
|
||||||
|
service {
|
||||||
|
connect {
|
||||||
|
sidecar_service {
|
||||||
|
proxy {
|
||||||
|
upstreams {
|
||||||
|
destination_name = "postgres"
|
||||||
|
local_bind_port = 5432
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task "sonarr" {
|
||||||
|
driver = "docker"
|
||||||
|
|
||||||
|
config {
|
||||||
|
image = "lscr.io/linuxserver/sonarr:latest"
|
||||||
|
ports = ["http"]
|
||||||
|
}
|
||||||
|
|
||||||
|
service {
|
||||||
|
name = "sonarr"
|
||||||
|
port = "http"
|
||||||
|
|
||||||
|
tags = [
|
||||||
|
"traefik.enable=true",
|
||||||
|
"traefik.http.routers.sonarr.middlewares=auth@file",
|
||||||
|
]
|
||||||
|
|
||||||
|
check {
|
||||||
|
name = "alive"
|
||||||
|
type = "tcp"
|
||||||
|
port = "http"
|
||||||
|
interval = "10s"
|
||||||
|
timeout = "2s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
env {
|
||||||
|
PUID = 1000
|
||||||
|
PGID = 1000
|
||||||
|
TZ = "Australia/Melbourne"
|
||||||
|
|
||||||
|
# https://wiki.servarr.com/sonarr/environment-variables
|
||||||
|
|
||||||
|
# Disable internal auth to use Traefik + Authelia
|
||||||
|
SONARR__AUTH__REQUIRED = "Enabled"
|
||||||
|
SONARR__AUTH__METHOD = "External"
|
||||||
|
|
||||||
|
SONARR__POSTGRES__USER = "sonarr"
|
||||||
|
SONARR__POSTGRES__HOST = "localhost"
|
||||||
|
SONARR__POSTGRES__PORT = "5432"
|
||||||
|
SONARR__POSTGRES__MAINDB = "sonarr-main"
|
||||||
|
SONARR__POSTGRES__LOGDB = "sonarr-log"
|
||||||
|
}
|
||||||
|
|
||||||
|
volume_mount {
|
||||||
|
volume = "unraid_appdata_sonarr"
|
||||||
|
destination = "/config"
|
||||||
|
read_only = false
|
||||||
|
}
|
||||||
|
|
||||||
|
volume_mount {
|
||||||
|
volume = "unraid_media_sonarr"
|
||||||
|
destination = "/data"
|
||||||
|
read_only = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resources {
|
||||||
|
cpu = 150
|
||||||
|
memory = 1024
|
||||||
|
}
|
||||||
|
|
||||||
|
template {
|
||||||
|
data = <<EOH
|
||||||
|
SONARR__POSTGRES__PASSWORD="{{ with nomadVar "nomad/jobs/sonarr" }}{{ .database_pw }}{{ end }}"
|
||||||
|
EOH
|
||||||
|
destination = "secrets/db.env"
|
||||||
|
env = true # Load the file as environment variables
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volume "unraid_appdata_sonarr" {
|
||||||
|
type = "csi"
|
||||||
|
read_only = false
|
||||||
|
source = "unraid_appdata_sonarr"
|
||||||
|
access_mode = "single-node-writer"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
|
||||||
|
mount_options {
|
||||||
|
mount_flags = ["uid=1000", "gid=1000"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volume "unraid_media_sonarr" {
|
||||||
|
type = "csi"
|
||||||
|
read_only = false
|
||||||
|
source = "unraid_media_sonarr"
|
||||||
|
access_mode = "single-node-writer"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
|
||||||
|
mount_options {
|
||||||
|
mount_flags = ["nobrl", "uid=1000", "gid=1000"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
78
2-nomad-config/sonarr.tf
Normal file
78
2-nomad-config/sonarr.tf
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
resource "nomad_job" "sonarr" {
|
||||||
|
jobspec = file("sonarr.nomad.hcl")
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "nomad_variable" "sonarr" {
|
||||||
|
path = "nomad/jobs/sonarr"
|
||||||
|
items = {
|
||||||
|
database_pw = data.sops_file.secrets.data["sonarr.database_pw"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# https://wiki.servarr.com/sonarr/postgres-setup#schema-creation
|
||||||
|
resource "postgresql_role" "sonarr" {
|
||||||
|
name = "sonarr"
|
||||||
|
password = data.sops_file.secrets.data["sonarr.database_pw"]
|
||||||
|
login = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "postgresql_database" "sonarr_main" {
|
||||||
|
name = "sonarr-main"
|
||||||
|
owner = postgresql_role.sonarr.name
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "postgresql_database" "sonarr_log" {
|
||||||
|
name = "sonarr-log"
|
||||||
|
owner = postgresql_role.sonarr.name
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "nomad_csi_volume_registration" "unraid_appdata_sonarr" {
|
||||||
|
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||||
|
depends_on = [data.nomad_plugin.smb]
|
||||||
|
plugin_id = "smb"
|
||||||
|
|
||||||
|
volume_id = "unraid_appdata_sonarr"
|
||||||
|
name = "unraid_appdata_sonarr"
|
||||||
|
|
||||||
|
external_id = "unraid_appdata_sonarr"
|
||||||
|
|
||||||
|
capability {
|
||||||
|
access_mode = "single-node-writer"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
}
|
||||||
|
|
||||||
|
context = {
|
||||||
|
source = "//betelgeuse-seven-unraid.lan/appdata"
|
||||||
|
subDir = "sonarr" # Note: Needs to be manually created on the share
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets = {
|
||||||
|
"username" = "nomad"
|
||||||
|
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "nomad_csi_volume_registration" "unraid_media_sonarr" {
|
||||||
|
#Note: Before chaning the definition of this volume you need to stop the jobs that are using it
|
||||||
|
depends_on = [data.nomad_plugin.smb]
|
||||||
|
plugin_id = "smb"
|
||||||
|
|
||||||
|
volume_id = "unraid_media_sonarr"
|
||||||
|
name = "unraid_media_sonarr"
|
||||||
|
|
||||||
|
external_id = "unraid_media_sonarr"
|
||||||
|
|
||||||
|
capability {
|
||||||
|
access_mode = "single-node-writer"
|
||||||
|
attachment_mode = "file-system"
|
||||||
|
}
|
||||||
|
|
||||||
|
context = {
|
||||||
|
source = "//betelgeuse-seven-unraid.lan/media"
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets = {
|
||||||
|
"username" = "nomad"
|
||||||
|
"password" = data.sops_file.secrets.data["unraid.nomad"]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user