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
resources = var.resources
service_tags = var.service_tags
custom_services = var.custom_services
ingress = var.ingress
ingress_rule = var.ingress_rule

View File

@ -84,6 +84,16 @@ job "${name}" {
}
%{ 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}" {
driver = "docker"

View File

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