github.com/hernad/nomad@v1.6.112/e2e/workload_id/input/node-meta.nomad.hcl (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  variable "foo_key" {
     5    type = string
     6  }
     7  
     8  variable "empty_key" {
     9    type = string
    10  }
    11  
    12  variable "unset_key" {
    13    type = string
    14  }
    15  
    16  variable "foo_constraint" {
    17    type = string
    18  }
    19  
    20  variable "empty_constraint" {
    21    type = string
    22  }
    23  
    24  variable "unset_constraint" {
    25    type = string
    26  }
    27  
    28  job "node-meta" {
    29    type = "batch"
    30  
    31    constraint {
    32      attribute = "${attr.kernel.name}"
    33      value     = "linux"
    34    }
    35  
    36    constraint {
    37      attribute = var.foo_constraint
    38      value     = "bar"
    39    }
    40  
    41    constraint {
    42      attribute = var.empty_constraint
    43      operator  = "is_set"
    44    }
    45  
    46    constraint {
    47      attribute = var.unset_constraint
    48      operator  = "is_not_set"
    49    }
    50  
    51    group "node-meta" {
    52  
    53      // sets keyUnset
    54      task "docker-nm" {
    55        driver = "docker"
    56  
    57        config {
    58          image = "curlimages/curl:7.87.0"
    59          args = [
    60            "--unix-socket", "${NOMAD_SECRETS_DIR}/api.sock",
    61            "-H", "Authorization: Bearer ${NOMAD_TOKEN}",
    62            "--data-binary", "{\"Meta\": {\"${var.unset_key}\": \"set\"}}",
    63            "--fail-with-body",
    64            "--verbose",
    65            "localhost/v1/client/metadata",
    66          ]
    67        }
    68  
    69        identity {
    70          env = true
    71        }
    72  
    73        resources {
    74          cpu    = 16
    75          memory = 32
    76          disk   = 64
    77        }
    78      }
    79  
    80      // unsets keyEmpty
    81      task "exec-nm" {
    82        driver = "exec"
    83  
    84        config {
    85          command = "curl"
    86          args = [
    87            "-H", "Authorization: Bearer ${NOMAD_TOKEN}",
    88            "--unix-socket", "${NOMAD_SECRETS_DIR}/api.sock",
    89            "--data-binary", "{\"Meta\": {\"${var.empty_key}\": null}}",
    90            "--fail-with-body",
    91            "--verbose",
    92            "localhost/v1/client/metadata",
    93          ]
    94        }
    95  
    96        identity {
    97          env = true
    98        }
    99  
   100        resources {
   101          cpu    = 16
   102          memory = 32
   103          disk   = 64
   104        }
   105      }
   106    }
   107  }