2022-10-27 21:28:34 +00:00
|
|
|
# module "nextcloud" {
|
|
|
|
# source = "./nextcloud"
|
|
|
|
#
|
|
|
|
# depends_on = [module.databases]
|
|
|
|
# }
|
|
|
|
|
|
|
|
module "backups" {
|
|
|
|
source = "./backups"
|
|
|
|
|
|
|
|
# In parent module
|
|
|
|
# depends_on = [module.databases]
|
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2023-03-24 18:24:36 +00:00
|
|
|
# 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]
|
|
|
|
#
|
|
|
|
# name = "nzbget"
|
|
|
|
# kind = "service-intentions"
|
|
|
|
#
|
|
|
|
# config_json = jsonencode({
|
|
|
|
# Sources = [
|
|
|
|
# {
|
|
|
|
# Action = "allow"
|
|
|
|
# Name = "sonarr"
|
|
|
|
# Precedence = 9
|
|
|
|
# Type = "consul"
|
|
|
|
# },
|
|
|
|
# ]
|
|
|
|
# })
|
|
|
|
# }
|
2022-10-27 21:28:34 +00:00
|
|
|
|
2023-03-02 19:01:44 +00:00
|
|
|
module "media-library" {
|
|
|
|
source = "./service"
|
|
|
|
|
|
|
|
name = "media-library"
|
|
|
|
image = "caddy"
|
|
|
|
args = ["caddy", "file-server", "--root", "/mnt/media", "--browse"]
|
|
|
|
ingress = true
|
|
|
|
service_port = 80
|
|
|
|
host_volumes = [
|
|
|
|
{
|
|
|
|
name = "media-read"
|
|
|
|
dest = "/mnt/media"
|
|
|
|
read_only = true
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-11-15 17:02:57 +00:00
|
|
|
module "minitor" {
|
|
|
|
source = "./service"
|
2022-11-10 19:15:43 +00:00
|
|
|
|
2022-11-15 17:02:57 +00:00
|
|
|
name = "minitor"
|
|
|
|
image = "iamthefij/minitor-go:1.1"
|
2023-03-02 19:01:44 +00:00
|
|
|
args = ["-metrics", "-config=$${NOMAD_TASK_DIR}/config.yml"]
|
2022-11-15 17:02:57 +00:00
|
|
|
service_port = 8080
|
|
|
|
metrics_port_name = "main"
|
2022-11-11 21:34:08 +00:00
|
|
|
|
2022-11-15 17:02:57 +00:00
|
|
|
templates = [
|
|
|
|
{
|
|
|
|
data = <<EOF
|
2023-03-24 18:24:36 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/minitor" -}}
|
|
|
|
MAILGUN_API_KEY={{ .mailgun_api_key }}
|
2022-11-15 17:02:57 +00:00
|
|
|
{{ end -}}
|
|
|
|
EOF
|
|
|
|
dest = "env"
|
|
|
|
dest_prefix = "$${NOMAD_SECRETS_DIR}/"
|
|
|
|
env = true
|
|
|
|
},
|
|
|
|
{
|
2022-11-16 17:04:32 +00:00
|
|
|
data = file("${path.module}/minitor-config.yml")
|
|
|
|
left_delimiter = "[["
|
|
|
|
right_delimiter = "]]"
|
|
|
|
dest = "config.yml"
|
|
|
|
mount = false
|
2022-11-15 17:02:57 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
2022-11-11 21:34:08 +00:00
|
|
|
|
|
|
|
module "photoprism_module" {
|
|
|
|
source = "./service"
|
|
|
|
|
2023-02-27 19:51:28 +00:00
|
|
|
name = "photoprism"
|
|
|
|
image = "photoprism/photoprism:221118-jammy"
|
|
|
|
image_pull_timeout = "10m"
|
|
|
|
ingress = true
|
|
|
|
service_port = 2342
|
|
|
|
sticky_disk = true
|
|
|
|
healthcheck_path = "/library/login"
|
2022-11-11 21:34:08 +00:00
|
|
|
env = {
|
2023-02-27 19:51:28 +00:00
|
|
|
PHOTOPRISM_DEBUG = true
|
2022-11-12 00:21:47 +00:00
|
|
|
# UI
|
2022-11-11 21:34:08 +00:00
|
|
|
PHOTOPRISM_SITE_CAPTION = "AI-Powered Photos App"
|
|
|
|
PHOTOPRISM_SITE_DESCRIPTION = "Fijolek home photos"
|
|
|
|
PHOTOPRISM_SITE_TITLE = "PhotoPrism"
|
2022-11-15 16:59:43 +00:00
|
|
|
PHOTOPRISM_SITE_URL = "https://photoprism.thefij.rocks/"
|
2022-11-11 21:34:08 +00:00
|
|
|
PHOTOPRISM_SPONSOR = "true"
|
2022-11-12 00:21:47 +00:00
|
|
|
# Worker config
|
|
|
|
PHOTOPRISM_WORKERS = 2
|
2022-11-11 21:34:08 +00:00
|
|
|
# Paths
|
|
|
|
PHOTOPRISM_ORIGINALS_PATH = "/photoprism-media/Library"
|
|
|
|
PHOTOPRISM_IMPORT_PATH = "/photoprism-media/Import"
|
2023-02-27 19:51:28 +00:00
|
|
|
PHOTOPRISM_STORAGE_PATH = "/photoprism-storage" # Storage PATH for generated files like cache and thumbnails
|
2022-11-11 21:34:08 +00:00
|
|
|
# Unix permissions
|
|
|
|
PHOTOPRISM_UID = 500
|
|
|
|
PHOTOPRISM_GID = 100
|
|
|
|
PHOTOPRISM_UMASK = 0000
|
|
|
|
}
|
|
|
|
resources = {
|
2023-03-02 18:39:42 +00:00
|
|
|
cpu = 2000
|
|
|
|
memory = 3000
|
|
|
|
memory_max = 4000
|
2022-11-11 21:34:08 +00:00
|
|
|
}
|
|
|
|
use_mysql = true
|
|
|
|
use_vault = true
|
|
|
|
host_volumes = [
|
2023-02-27 19:51:28 +00:00
|
|
|
{
|
|
|
|
name = "photoprism-storage"
|
|
|
|
dest = "/photoprism-storage"
|
|
|
|
read_only = false
|
|
|
|
},
|
2022-11-11 21:34:08 +00:00
|
|
|
{
|
|
|
|
name = "photoprism-media"
|
|
|
|
dest = "/photoprism-media"
|
|
|
|
read_only = false
|
|
|
|
},
|
|
|
|
]
|
|
|
|
mysql_bootstrap = {
|
2023-03-24 18:24:36 +00:00
|
|
|
vault_key = "nomad/jobs/photoprism"
|
2022-11-10 19:15:43 +00:00
|
|
|
}
|
2022-11-11 21:34:08 +00:00
|
|
|
templates = [
|
|
|
|
{
|
|
|
|
data = <<EOF
|
2023-03-24 18:24:36 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/photoprism" -}}
|
|
|
|
PHOTOPRISM_ADMIN_USER={{ .admin_user }}
|
|
|
|
PHOTOPRISM_ADMIN_PASSWORD={{ .admin_password }}
|
2022-11-11 21:34:08 +00:00
|
|
|
PHOTOPRISM_DATABASE_DRIVER=mysql
|
2023-03-24 18:24:36 +00:00
|
|
|
PHOTOPRISM_DATABASE_NAME={{ .db_name }}
|
|
|
|
PHOTOPRISM_DATABASE_USER={{ .db_user }}
|
|
|
|
PHOTOPRISM_DATABASE_PASSWORD={{ .db_pass }}
|
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "mysql-server" -}}
|
|
|
|
PHOTOPRISM_DATABASE_SERVER="{{ .Address" }}:{{ .Port }}"
|
2022-11-11 21:34:08 +00:00
|
|
|
{{ end -}}
|
|
|
|
EOF
|
|
|
|
dest_prefix = "$${NOMAD_SECRETS_DIR}/"
|
|
|
|
dest = "env"
|
|
|
|
env = true
|
|
|
|
mount = false
|
|
|
|
},
|
|
|
|
]
|
2022-11-10 19:15:43 +00:00
|
|
|
}
|
2023-01-12 20:11:16 +00:00
|
|
|
|
|
|
|
module "diun" {
|
|
|
|
source = "./service"
|
|
|
|
|
|
|
|
name = "diun"
|
|
|
|
image = "crazymax/diun:4.24"
|
|
|
|
args = ["serve", "--log-level=debug"]
|
|
|
|
|
|
|
|
env = {
|
|
|
|
DIUN_DB_PATH = "$${NOMAD_TASK_DIR}/diun.db"
|
|
|
|
DIUN_WATCH_SCHEDULE = "0 */6 * * *"
|
|
|
|
DIUN_PROVIDERS_NOMAD_WATCHBYDEFAULT = true
|
|
|
|
|
|
|
|
# Nomad API
|
|
|
|
NOMAD_ADDR = "http://$${attr.unique.network.ip-address}:4646/"
|
|
|
|
DIUN_PROVIDERS_NOMAD = true
|
|
|
|
}
|
|
|
|
|
|
|
|
use_vault = true
|
|
|
|
|
|
|
|
templates = [
|
|
|
|
{
|
|
|
|
data = <<EOF
|
2023-03-24 18:24:36 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/diun" -}}
|
|
|
|
DIUN_NOTIF_SLACK_WEBHOOKURL={{ .slack_hook_url }}
|
|
|
|
{{- end }}
|
2023-01-12 20:11:16 +00:00
|
|
|
EOF
|
|
|
|
dest_prefix = "$${NOMAD_SECRETS_DIR}"
|
|
|
|
dest = "env"
|
|
|
|
env = true
|
|
|
|
mount = false
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|