Add image_pull_timeout to service template

This commit is contained in:
IamTheFij 2023-02-27 11:48:24 -08:00
parent 5341cb1c8b
commit 9fe63d03d9
3 changed files with 16 additions and 6 deletions

View File

@ -1,11 +1,12 @@
resource "nomad_job" "service" { resource "nomad_job" "service" {
jobspec = templatefile("${path.module}/service_template.nomad", { jobspec = templatefile("${path.module}/service_template.nomad", {
name = var.name name = var.name
image = var.image image = var.image
args = var.args image_pull_timeout = var.image_pull_timeout
env = var.env args = var.args
meta = var.meta env = var.env
group_meta = var.group_meta meta = var.meta
group_meta = var.group_meta
service_port = var.service_port service_port = var.service_port
sticky_disk = var.sticky_disk sticky_disk = var.sticky_disk

View File

@ -131,6 +131,9 @@ job "${name}" {
%{ endif ~} %{ endif ~}
config { config {
image = "${image}" image = "${image}"
%{if image_pull_timeout != null ~}
image_pull_timeout = "${image_pull_timeout}"
%{ endif ~}
%{ if service_port != null ~} %{ if service_port != null ~}
ports = ["main"] ports = ["main"]
%{ endif ~} %{ endif ~}

View File

@ -8,6 +8,12 @@ variable "image" {
description = "Image that should be run" description = "Image that should be run"
} }
variable "image_pull_timeout" {
type = string
default = null
description = "A time duration that controls how long Nomad will wait before cancelling an in-progress pull of the Docker image"
}
variable "meta" { variable "meta" {
type = map(string) type = map(string)
default = {} default = {}