github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/consultemplate/input/nomad_provider_service_lookup.nomad (about)

     1  job "nomad_provider_service_lookup" {
     2    datacenters = ["dc1"]
     3    type        = "service"
     4  
     5    constraint {
     6      attribute = "${attr.kernel.name}"
     7      value     = "linux"
     8    }
     9  
    10    group "nomad_provider_service_lookup" {
    11  
    12      task "test" {
    13        driver = "raw_exec"
    14  
    15        config {
    16          command = "bash"
    17          args    = ["-c", "sleep 15000"]
    18        }
    19  
    20        template {
    21          data = <<EOH
    22  {{ range nomadServices }}
    23  service {{ .Name }} {{ .Tags }}{{ end }}
    24  EOH
    25  
    26          destination = "${NOMAD_TASK_DIR}/services.conf"
    27          change_mode = "restart"
    28        }
    29  
    30        template {
    31          data = <<EOH
    32  {{ range nomadService "default-nomad-provider-service-primary" }}
    33  service {{ .Name }} {{ .Tags }} {{ .Datacenter }} {{ .AllocID }}{{ end }}
    34  EOH
    35  
    36          destination = "${NOMAD_TASK_DIR}/service.conf"
    37          change_mode = "noop"
    38        }
    39      }
    40    }
    41  }