Using meta tags in job configuration

Hi,

Is it possible to use meta tags (in my instance in a group) to use it within the further configuration?

Code snippet:

group "website-prod" {
  count = 1

  meta {
    web-type = "production"
    web-fqdn = "production.website.example.com"
  }

  network {
    port "http" {
      to = 80
    }
  }

  service {
    name = "website-${web-type}"
    port = "http"

    tags = [
      "traefik.enable=true",
      "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https",
      "traefik.http.routers.website-${web-type}-redirect.rule=Host(`${web-fqdn}`)",
      "traefik.http.routers.website-${web-type}-redirect.entrypoints=http",
      "traefik.http.routers.website-${web-type}-redirect.middlewares=redirect-to-https",
      "traefik.http.routers.website-${web-type}.tls=true",
      "traefik.http.routers.website-${web-type}.entrypoints=https",
      "traefik.http.routers.website-${web-type}.rule=Host(`${envy-fqdn}`)",
    ]
  }
}

When I use this, it will just literally put ${web-type} and ${web-fqdn} in the job and fail.

Hi @chrisvanmeer; yes it is possible to interpolate meta values in service tags. The syntax for doing this as detailed on the Nomad runtime interpolation page would look like traefik.http.routers.website-${NOMAD_META_web-type}.tls=true.

Thanks,
jrasell and the Nomad team

2 Likes