Add ability to set docker user for services

This commit is contained in:
IamTheFij 2024-06-26 13:30:50 -07:00
parent bd67c60575
commit c5743a2578
3 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,7 @@ resource "nomad_job" "service" {
job_meta = var.job_meta
constraints = var.constraints
docker_devices = var.docker_devices
user = var.user
service_port = var.service_port
service_port_static = var.service_port_static

View File

@ -80,6 +80,9 @@ job "${name}" {
task "${name}" {
driver = "docker"
%{~ if user != null }
user = "${user}"
%{~ endif ~}
%{~ if length(task_meta) > 0 }
meta = {
%{ for k, v in task_meta ~}

View File

@ -32,6 +32,12 @@ variable "image_pull_timeout" {
description = "A time duration that controls how long Nomad will wait before cancelling an in-progress pull of the Docker image"
}
variable "user" {
type = string
default = null
description = "User to be passed to the task driver for execution. [ user | user:group | uid | uid:gid | user:gid | uid:group ]"
}
variable "task_meta" {
type = map(string)
default = {}