module "blocky" {
  source = "./blocky"

  base_hostname = var.base_hostname
  # Not in this module
  # depends_on = [module.databases]
}

module "traefik" {
  source = "./traefik"

  base_hostname = var.base_hostname
}

module "metrics" {
  source = "./metrics"
  # Not in this module
  # depends_on = [module.databases]
}

resource "nomad_job" "nomad-client-stalker" {
  # Stalker used to allow using Nomad service registry to identify nomad client hosts
  jobspec = file("${path.module}/nomad-client-stalker.nomad")
}

module "loki" {
  source = "../services/service"

  name         = "loki"
  image        = "grafana/loki:2.2.1"
  args         = ["--config.file=$${NOMAD_TASK_DIR}/loki-config.yml"]
  service_port = 3100
  ingress      = true
  sticky_disk  = true
  # healthcheck  = "/ready"
  templates = [
    {
      data  = file("${path.module}/loki-config.yml")
      dest  = "loki-config.yml"
      mount = false
    }
  ]
}

resource "nomad_job" "syslog-ng" {
  jobspec = file("${path.module}/syslogng.nomad")
}

resource "nomad_job" "ddclient" {
  jobspec = file("${path.module}/ddclient.nomad")
}

resource "nomad_job" "lldap" {
  jobspec = file("${path.module}/lldap.nomad")
}