From df1ae60936124674c1bd1744a20b9fb1c70a240d Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 6 Nov 2023 14:41:13 -0800 Subject: [PATCH] Add change_script to service module --- services/service/service_template.nomad | 8 ++++++++ services/service/vars.tf | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/service/service_template.nomad b/services/service/service_template.nomad index b911591..ccc4b04 100644 --- a/services/service/service_template.nomad +++ b/services/service/service_template.nomad @@ -175,6 +175,14 @@ EOF %{~ if template.change_signal != null } change_signal = "${template.change_signal}" %{~ endif ~} + %{~ if template.change_script != null } + change_script { + command = "${template.change_script.command}" + args = ${jsonencode(template.change_script.args)} + timeout = "${template.change_script.timeout}" + fail_on_error = ${template.change_script.fail_on_error} + } + %{~ endif ~} %{~ if template.env != null } env = ${template.env} %{~ endif ~} diff --git a/services/service/vars.tf b/services/service/vars.tf index 09d0d4a..c96d409 100644 --- a/services/service/vars.tf +++ b/services/service/vars.tf @@ -158,12 +158,18 @@ variable "templates" { data = string dest = string dest_prefix = optional(string, "$${NOMAD_TASK_DIR}") - change_mode = optional(string) - change_signal = optional(string) left_delimiter = optional(string) right_delimiter = optional(string) mount = optional(bool, true) env = optional(bool, false) + change_mode = optional(string) + change_signal = optional(string) + change_script = optional(object({ + command = optional(string, "") + args = optional(list(string), []) + timeout = optional(string, "5s") + fail_on_error = optional(bool, false) + })) })) default = [] description = "Templates to be used"