Add ability to specify custom services for service module

This commit is contained in:
IamTheFij 2023-07-24 15:21:20 -07:00
parent 6524631a53
commit b9fb2d4b07
3 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,7 @@ resource "nomad_job" "service" {
sticky_disk = var.sticky_disk sticky_disk = var.sticky_disk
resources = var.resources resources = var.resources
service_tags = var.service_tags service_tags = var.service_tags
custom_services = var.custom_services
ingress = var.ingress ingress = var.ingress
ingress_rule = var.ingress_rule ingress_rule = var.ingress_rule

View File

@ -84,6 +84,16 @@ job "${name}" {
} }
%{ endif ~} %{ endif ~}
%{ for custom_service in custom_services }
service {
name = "${custom_service.name}"
provider = "nomad"
port = "${custom_service.port}"
tags = ${jsonencode(custom_service.tags)}
}
%{ endfor }
task "${name}" { task "${name}" {
driver = "docker" driver = "docker"

View File

@ -172,6 +172,7 @@ variable "mysql_bootstrap" {
db_pass_key = optional(string, "db_pass") db_pass_key = optional(string, "db_pass")
add_ro = optional(bool, false) add_ro = optional(bool, false)
}) })
default = null default = null
} }
@ -181,6 +182,7 @@ variable "constraints" {
operator = optional(string, "=") operator = optional(string, "=")
value = optional(string, "") value = optional(string, "")
})) }))
default = [] default = []
} }
@ -192,3 +194,14 @@ variable "docker_devices" {
default = [] default = []
} }
variable "custom_services" {
description = "Service definitions for any additional requested services."
type = list(object({
name = string
port = string
tags = list(string)
}))
default = []
}