diff --git a/ansible_playbooks/setup-cluster.yml b/ansible_playbooks/setup-cluster.yml index d7c723c..65d0da3 100644 --- a/ansible_playbooks/setup-cluster.yml +++ b/ansible_playbooks/setup-cluster.yml @@ -239,6 +239,9 @@ - name: media-downloads path: /srv/volumes/media-write/Downloads read_only: false + - name: sabnzbd-config + path: /srv/volumes/media-write/Downloads/sabnzbd + read_only: false - name: photoprism-media path: /srv/volumes/photos/Photoprism read_only: false diff --git a/services/backups/jobs/sabnzbd.hcl b/services/backups/jobs/sabnzbd.hcl new file mode 100644 index 0000000..42c3862 --- /dev/null +++ b/services/backups/jobs/sabnzbd.hcl @@ -0,0 +1,26 @@ +job "sabnzbd" { + schedule = "@daily" + + config { + repo = "rclone::ftp,env_auth:/nomad/sabnzbd" + passphrase = env("BACKUP_PASSPHRASE") + } + + backup { + paths = ["/data/media-write/Downloads/sabnzbd"] + # Because path is absolute + restore_opts { + Target = "/" + } + } + + forget { + KeepLast = 2 + KeepHourly = 24 + KeepDaily = 30 + KeepWeekly = 8 + KeepMonthly = 6 + KeepYearly = 2 + Prune = true + } +} diff --git a/services/ip-dvr.nomad b/services/ip-dvr.nomad index 4c9b245..4da7832 100644 --- a/services/ip-dvr.nomad +++ b/services/ip-dvr.nomad @@ -4,6 +4,88 @@ job "ipdvr" { type = "service" + group "sabnzbd" { + network { + mode = "bridge" + + port "main" { + host_network = "loopback" + to = 8080 + } + } + + volume "sabnzbd-config" { + type = "host" + read_only = false + source = "sabnzbd-config" + } + + volume "media-downloads" { + type = "host" + read_only = false + source = "media-downloads" + } + + service { + name = "sabnzbd" + port = "main" + + connect { + sidecar_service { + proxy { + local_service_port = 8080 + } + } + + sidecar_task { + resources { + cpu = 50 + memory = 20 + memory_max = 50 + } + } + } + + tags = [ + "traefik.enable=true", + "traefik.http.routers.sabnzbd.entryPoints=websecure", + ] + } + + task "sabnzbd" { + driver = "docker" + + config { + image = "linuxserver/sabnzbd" + ports = ["main"] + } + + env = { + "PGID" = 100 + "PUID" = 1001 + "TZ" = "America/Los_Angeles" + } + + volume_mount { + volume = "sabnzbd-config" + destination = "/config" + read_only = false + } + + volume_mount { + volume = "media-downloads" + destination = "/downloads" + read_only = false + } + + resources { + cpu = 400 + memory = 500 + memory_max = 800 + } + } + } + group "nzbget" { network { mode = "bridge" @@ -127,6 +209,11 @@ job "ipdvr" { destination_name = "nzbget" local_bind_port = 6789 } + + upstreams { + destination_name = "sabnzbd" + local_bind_port = 8080 + } } } diff --git a/services/main.tf b/services/main.tf index 36ab929..fb26b1c 100644 --- a/services/main.tf +++ b/services/main.tf @@ -31,6 +31,24 @@ resource "nomad_job" "ipdvr" { jobspec = file("${path.module}/ip-dvr.nomad") } +resource "consul_config_entry" "sabnzbd_intents" { + depends_on = [nomad_job.ipdvr] + + name = "sabnzbd" + kind = "service-intentions" + + config_json = jsonencode({ + Sources = [ + { + Action = "allow" + Name = "sonarr" + Precedence = 9 + Type = "consul" + }, + ] + }) +} + resource "consul_config_entry" "nzbget_intents" { depends_on = [nomad_job.ipdvr]