github.com/hernad/nomad@v1.6.112/ui/app/utils/default_jobs/parameterized.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  export default `job "parameterized-job" {
     7    // Specifies the datacenter where this job should be run
     8    // This can be omitted and it will default to ["*"]
     9    datacenters = ["*"]
    10  
    11    // Unlike service jobs, Batch jobs are intended to run until they exit successfully.
    12    type = "batch"
    13  
    14    // Run the job only on Linux or MacOS.
    15    constraint {
    16      attribute = "\${attr.kernel.name}"
    17      operator  = "set_contains_any"
    18      value     = "darwin,linux"
    19    }
    20  
    21    // Allow the job to be parameterized, and allow any meta key with
    22    // a name starting with "i" to be specified.
    23    parameterized {
    24      meta_optional = ["MY_META_KEY"]
    25    }
    26  
    27    group "group" {
    28      task "task" {
    29        driver = "docker"
    30        config {
    31          image   = "busybox:1"
    32          command = "/bin/sh"
    33          args    = ["-c", "cat local/template.out", "local/payload.txt"]
    34        }
    35  
    36        dispatch_payload {
    37          file = "payload.txt"
    38        }
    39  
    40        template {
    41          data = <<EOH
    42  MY_META_KEY: {{env "NOMAD_META_MY_META_KEY"}}
    43    EOH
    44  
    45          destination = "local/template.out"
    46        }
    47      }
    48    }
    49  }`;