github.com/hernad/nomad@v1.6.112/e2e/consultemplate/input/template_shared_alloc.nomad (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  job "template-shared-alloc" {
     5    datacenters = ["dc1", "dc2"]
     6  
     7    constraint {
     8      attribute = "${attr.kernel.name}"
     9      value     = "linux"
    10    }
    11  
    12    group "template-paths" {
    13  
    14      task "raw_exec" {
    15        driver = "raw_exec"
    16        config {
    17          command = "/bin/sh"
    18          args    = ["-c", "sleep 300"]
    19        }
    20  
    21        lifecycle {
    22          hook    = "prestart"
    23          sidecar = true
    24        }
    25  
    26        artifact {
    27          source      = "https://google.com"
    28          destination = "../alloc/google1.html"
    29        }
    30  
    31        template {
    32          destination = "${NOMAD_ALLOC_DIR}/${NOMAD_TASK_NAME}.env"
    33          data        = <<EOH
    34  {{env "NOMAD_ALLOC_DIR"}}
    35  EOH
    36        }
    37  
    38        template {
    39          destination = "${NOMAD_ALLOC_DIR}/hello-from-raw.env"
    40          data        = <<EOH
    41  HELLO_FROM={{env "NOMAD_TASK_NAME"}}
    42  EOH
    43          env         = true
    44        }
    45  
    46        resources {
    47          cpu    = 128
    48          memory = 64
    49        }
    50  
    51      }
    52  
    53      task "docker" {
    54        driver = "docker"
    55        config {
    56          image   = "busybox:1"
    57          command = "/bin/sh"
    58          args    = ["-c", "sleep 300"]
    59        }
    60  
    61        artifact {
    62          source      = "https://google.com"
    63          destination = "../alloc/google2.html"
    64        }
    65  
    66        template {
    67          destination = "${NOMAD_ALLOC_DIR}/${NOMAD_TASK_NAME}.env"
    68          data        = <<EOH
    69  {{env "NOMAD_ALLOC_DIR"}}
    70  EOH
    71        }
    72  
    73        template {
    74          source      = "${NOMAD_ALLOC_DIR}/hello-from-raw.env"
    75          destination = "${NOMAD_LOCAL_DIR}/hello-from-raw.env"
    76          env         = true
    77        }
    78  
    79        resources {
    80          cpu    = 128
    81          memory = 64
    82        }
    83      }
    84  
    85      task "exec" {
    86        driver = "exec"
    87        config {
    88          command = "/bin/sh"
    89          args    = ["-c", "sleep 300"]
    90        }
    91  
    92        artifact {
    93          source      = "https://google.com"
    94          destination = "${NOMAD_ALLOC_DIR}/google3.html"
    95        }
    96  
    97        template {
    98          destination = "${NOMAD_ALLOC_DIR}/${NOMAD_TASK_NAME}.env"
    99          data        = <<EOH
   100  {{env "NOMAD_ALLOC_DIR"}}
   101  EOH
   102        }
   103  
   104        template {
   105          source      = "${NOMAD_ALLOC_DIR}/hello-from-raw.env"
   106          destination = "${NOMAD_LOCAL_DIR}/hello-from-raw.env"
   107          env         = true
   108        }
   109  
   110        resources {
   111          cpu    = 128
   112          memory = 64
   113        }
   114      }
   115  
   116    }
   117  }