diff --git a/quake.tf b/quake.tf index 124a4c3..0359434 100644 --- a/quake.tf +++ b/quake.tf @@ -2,5 +2,9 @@ resource "nomad_job" "quake" { jobspec = templatefile("${path.module}/quake/quake.hcl", { datacenter = var.datacenter rcon_password = var.rcon_password + service_meta = merge({ + protocol = "udp" + port = 27500 + }, var.service_meta) }) } diff --git a/quake/quake.hcl b/quake/quake.hcl index cd328fe..edf20ed 100644 --- a/quake/quake.hcl +++ b/quake/quake.hcl @@ -13,6 +13,23 @@ job "quake" { } task "nquakesv" { + service { + meta = { + %{for key, value in service_meta} + "${key}" = "${value}" + %{endfor} + } + + port = "quake" + + check { + type = "tcp" + port = "quake" + interval = "10s" + timeout = "2s" + } + } + driver = "docker" config { diff --git a/variables.tf b/variables.tf index 4801345..f3193b8 100644 --- a/variables.tf +++ b/variables.tf @@ -8,3 +8,9 @@ variable "rcon_password" { type = string description = "The password for RCON (remote console)" } + +variable "service_meta" { + type = map(string) + default = {} + description = "Register the service in Consul with the given service metadata" +}