homelab-nomad/services/main.tf
2022-11-10 13:37:50 -08:00

191 lines
5.9 KiB
HCL

# module "nextcloud" {
# source = "./nextcloud"
#
# depends_on = [module.databases]
# }
module "backups" {
source = "./backups"
# In parent module
# depends_on = [module.databases]
}
module "media" {
source = "./media"
}
resource "nomad_job" "whoami" {
hcl2 {
enabled = true
vars = {
"count" = 1,
# "count" = "${2 * length(data.consul_service.nomad.service)}",
}
}
jobspec = file("${path.module}/whoami.nomad")
}
resource "nomad_job" "ipdvr" {
jobspec = file("${path.module}/ip-dvr.nomad")
}
resource "consul_config_entry" "nzbget_intents" {
depends_on = [nomad_job.ipdvr]
name = "nzbget"
kind = "service-intentions"
config_json = jsonencode({
Sources = [
{
Action = "allow"
Name = "sonarr"
Precedence = 9
Type = "consul"
},
]
})
}
# module "nzbget" {
# source "./levant"
#
# template_path = "service.nomad"
# variables = {
# name = "nzbget"
# image = "linuxserver/nzbget"
# service_port = 6789
# ingress = true
# env = jsonencode({
# PGID = 100
# PUID = 1001
# TZ = "America/Los_Angeles"
# })
# host_volumes = jsonencode([
# {
# name = "download"
# dest = "/srv/volumes/download"
# read_only = false
# },
# ])
# }
# }
#
# module "sonarr" {
# source = "./levant"
#
# template_path = "service.nomad"
# variables = {
# name = "sonarr"
# image = "linuxserver/sonarr"
# service_port = 8989
# ingress = true
# env = jsonencode({
# PGID = 100
# PUID = 1001
# TZ = "America/Los_Angeles"
#
# })
# host_volumes = jsonencode([
# {
# name = "sonarr-data"
# dest = "/config"
# read_only = false
# },
# {
# name = "tv-sonarr"
# dest = "/srv/volumes/media-write/TV Shows"
# read_only = false
# },
# {
# name = "download"
# dest = "/srv/volumes/download"
# read_only = false
# },
# ])
# }
# }
module "photoprism" {
source = "IamTheFij/levant/nomad"
version = "0.1.0"
template_path = "service.nomad"
variables = {
name = "photoprism"
image = "photoprism/photoprism:latest"
ingress = true
service_port = 2342
sticky_disk = true
healthcheck = "/library/login"
env = jsonencode({
PHOTOPRISM_DETECT_NSFW = "false" # automatically flags photos as private that MAY be offensive (requires TensorFlow)
PHOTOPRISM_DISABLE_CHOWN = "false" # disables updating storage permissions via chmod and chown on startup
PHOTOPRISM_DISABLE_CLASSIFICATION = "false" # disables image classification (requires TensorFlow)
PHOTOPRISM_DISABLE_FACES = "false" # disables face detection and recognition (requires TensorFlow)
PHOTOPRISM_DISABLE_RAW = "false" # disables indexing and conversion of RAW files
PHOTOPRISM_DISABLE_SETTINGS = "false" # disables settings UI and API
PHOTOPRISM_DISABLE_TENSORFLOW = "false" # disables all features depending on TensorFlow
PHOTOPRISM_DISABLE_WEBDAV = "false" # disables built-in WebDAV server
PHOTOPRISM_EXPERIMENTAL = "false" # enables experimental features
PHOTOPRISM_HTTP_COMPRESSION = "gzip" # improves transfer speed and bandwidth utilization (none or gzip)
PHOTOPRISM_JPEG_QUALITY = 85 # a higher value increases the quality and file size of JPEG images and thumbnails (25-100)
PHOTOPRISM_LOG_LEVEL = "info" # log level: trace, debug, info, warning, error, fatal, or panic
PHOTOPRISM_ORIGINALS_LIMIT = 5000 # file size limit for originals in MB (increase for high-res video)
PHOTOPRISM_RAW_PRESETS = "false" # enables applying user presets when converting RAW files (reduces performance)
PHOTOPRISM_READONLY = "false" # do not modify originals directory (reduced functionality)
PHOTOPRISM_SITE_AUTHOR = "" # meta site author
PHOTOPRISM_SITE_CAPTION = "AI-Powered Photos App"
PHOTOPRISM_SITE_DESCRIPTION = "" # meta site description
PHOTOPRISM_SITE_TITLE = "PhotoPrism"
PHOTOPRISM_SITE_URL = "http://localhost:2342/" # server URL in the format "http(s)://domain.name(:port)/(path)"
PHOTOPRISM_UPLOAD_NSFW = "true" # allows uploads that MAY be offensive (no effect without TensorFlow)
PHOTOPRISM_SPONSOR = "true"
# Paths
PHOTOPRISM_ORIGINALS_PATH = "/photoprism-media/Library"
PHOTOPRISM_IMPORT_PATH = "/photoprism-media/Import"
PHOTOPRISM_STORAGE_PATH = "$${NOMAD_TASK_DIR}/storage" # Storage PATH for generated files like cache and index
# Unix permissions
PHOTOPRISM_UID = 500
PHOTOPRISM_GID = 100
PHOTOPRISM_UMASK = 0000
})
mysql = true
vault = true
host_volumes = jsonencode([
{
name = "photoprism-media"
dest = "/photoprism-media"
read_only = false
},
])
mysql_bootstrap = jsonencode({
vault_key = "kv/data/photoprism"
db_name_key = "db_name"
db_user_key = "db_user"
db_pass_key = "db_pass"
})
templates = jsonencode([
{
data = <<EOF
{{ with secret "kv/data/photoprism" -}}
PHOTOPRISM_ADMIN_USER={{ .Data.data.admin_user }}
PHOTOPRISM_ADMIN_PASSWORD={{ .Data.data.admin_password }}
PHOTOPRISM_DATABASE_DRIVER=mysql
PHOTOPRISM_DATABASE_NAME={{ .Data.data.db_name }}
PHOTOPRISM_DATABASE_USER={{ .Data.data.db_user }}
PHOTOPRISM_DATABASE_PASSWORD={{ .Data.data.db_pass }}
PHOTOPRISM_DATABASE_SERVER="{{ env "NOMAD_UPSTREAM_ADDR_mysql_server" }}"
{{ end -}}
EOF
dest_prefix = "$${NOMAD_SECRETS_DIR}/"
dest = "env"
env = true
mount = false
},
])
}
}