environment-variablesnomad

nomad multiline environment variable


Is there a way to have a multiline environment variable in a nomad template? Trying it directly gives an error about not being able to find the closing quote.

In the docs the only function that's mentioned is | toJSON, but that translates the line feeds into \n so the receiving end needs to do a search-and-replace or some "unJSON" function.

I tried using HEREDOC syntax in the template, but that didn't seem to work either.


Solution

  • Using a here document works fine:

    job "example" {
      datacenters = ["dc1"]
      type = "service"
      group "cache" {
        task "redis" {
          driver = "docker"
          config {
            image = "redis:7"
          }
          env {
            EXAMPLE = <<EOF
    multiline
    varibale
    is
    here
    EOF
          }
        }
      }
    }