Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: it is not clear how to refer to nomad variables #24596

Closed
EugenKon opened this issue Dec 3, 2024 · 2 comments
Closed

Documentation: it is not clear how to refer to nomad variables #24596

EugenKon opened this issue Dec 3, 2024 · 2 comments
Labels

Comments

@EugenKon
Copy link

EugenKon commented Dec 3, 2024

Issue

https://developer.hashicorp.com/nomad/docs/job-specification/template#environment-variables

image

It is not clear how to refer to NOMAD_ALLOC_DIR

CERT_PEM={{ file "NOMAD_ALLOC_DIR/cert.pem" | toJSON }}

@philrenaud
Copy link
Contributor

Hi @EugenKon! You can read a bit more on variable interpolation over at https://developer.hashicorp.com/nomad/docs/runtime/interpolation

An example of how we might use NOMAD_ALLOC_DIR in a template block:

      template {
        data        = "<html>hello, world</html>"
        destination = "${NOMAD_ALLOC_DIR}/index.html"
      }

@EugenKon
Copy link
Author

EugenKon commented Dec 3, 2024

@philrenaud Your example works perfect. But that is not I am asking for.

Here Go template system tells that $ is not allowed here, thus I removed it from in the my original post.

template {
  data = <<EOH
    CERT_PEM={{ file "${NOMAD_ALLOC_DIR}/cert.pem" | toJSON }}
    EOH

  destination = "secrets/file.env"
  env         = true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants