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

${NOMAD_TASK_DIR} value not rendered in template body #15468

Closed
sssilver opened this issue Dec 4, 2022 · 3 comments
Closed

${NOMAD_TASK_DIR} value not rendered in template body #15468

sssilver opened this issue Dec 4, 2022 · 3 comments
Labels

Comments

@sssilver
Copy link

sssilver commented Dec 4, 2022

Nomad version

Nomad v1.4.3 (f464aca)

Operating system and Environment details

Ubuntu 22.04.1 LTS
Linux ironforge 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Issue

It looks like ${NOMAD_TASK_DIR} is not being rendered in my job template:

...
      template {
        destination = "${NOMAD_TASK_DIR}/config.yaml"
        change_mode = "restart"
        data = <<EOH
tunnel: f562a054-f138-4667-8799-3f5f9e996eae
credentials-file: ${NOMAD_TASK_DIR}/ironforge-credentials.json  # <------ Referencing the variable, expecting it to be substituted

metrics: :5000
no-autoupdate: true
warp-routing:
  enabled: true
ingress:
{{- range nomadService "hello" }}
- service: http://{{ .Address }}:{{ .Port }}
  hostname: ironforge.x17.space
{{- end }}

- service: http_status:404
EOH
      }

Here's the rendered template:

λ ~/projects/ironforge/ nomad alloc fs be37f4e6 cloudflared/local/config.yaml
tunnel: f562a054-f138-4667-8799-3f5f9e996eae
credentials-file: ${NOMAD_TASK_DIR}/ironforge-credentials.json  <-------- NOTICE: Templated value not rendered!!

metrics: :5000
no-autoupdate: true
warp-routing:
  enabled: true
ingress:
- service: http://192.168.86.36:26308
  hostname: ironforge.x17.space

- service: http_status:404

Am I missing something, or is this a bug?

Reproduction steps

  • Create a job with a template stanza that references ${NOMAD_TASK_DIR} in data
  • Run the job
  • Observe that the rendered template does not substitute the ${NOMAD_TASK_DIR} value

Expected Result

  • ${NOMAD_TASK_DIR} value is properly rendered from the template into the final file
@krundru
Copy link

krundru commented Dec 5, 2022

template follows {{ env "NOMAD_TASK_DIR" }} syntax.

For example, this is how we are rendering part of envoy yaml file

  - name: xds_cluster
    type: STATIC
    connect_timeout: 10s
    http2_protocol_options: {}
    load_assignment:
      cluster_name: xds_cluster
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: {{ env "attr.unique.network.ip-address" }}
                port_value: 5678

@sssilver
Copy link
Author

sssilver commented Dec 5, 2022

Thanks @krundru!

I'll close the issue, with the caveat that the docs could have been more clear on this.

@sssilver sssilver closed this as completed Dec 5, 2022
@github-actions
Copy link

github-actions bot commented Apr 5, 2023

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants