0

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.

Tim Tisdall
  • 9,914
  • 3
  • 52
  • 82

1 Answers1

1

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
      }
    }
  }
}
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • 1
    It's been half a year now so I don't recall exactly what I was doing, but maybe my issue was indenting the `EOF`. – Tim Tisdall Feb 17 '23 at 16:48