From 9d8a0dc72e2f20ff82bf095bcef7f02bf1bf4629 Mon Sep 17 00:00:00 2001 From: Adrienne Cohea Date: Fri, 17 Dec 2021 15:21:02 -0800 Subject: [PATCH] Add service meta --- quake.tf | 4 ++++ quake/quake.hcl | 17 +++++++++++++++++ variables.tf | 6 ++++++ 3 files changed, 27 insertions(+) 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" +}