hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.89k stars 1.95k forks source link

Option to provide path.job_spec variable(s) like terraform does path.module #19326

Open 116davinder opened 11 months ago

116davinder commented 11 months ago

Proposal

Request to provider internal variable to find job spec absolute path similar to what terraform provides

Ref: https://github.com/hashicorp/terraform/blob/main/internal/addrs/path_attr.go

Terraform Example

resource "local_file" "efs_volume_hcl" {
  count           = var.volumes ? 1 : 0
  content         = data.template_file.efs_volume_hcl[0].rendered
  filename        = "${path.module}/../csi/input/volume-efs.hcl" <---- here
  file_permission = "0664"
}

Nomad Proposed Example

file("${path.job_spec}/hello.txt")

Use-cases

Since most of my jobs requires templates and I want to reuse them with following syntax so that i can find right folder for templates.

      template {
        data        = file("/path/to/example/file.txt")
        destination = "local/file.txt"
      }

Attempted Solutions

N/A

tgross commented 10 months ago

Hi @116davinder! This seems possible. I'll add it to the roadmap, but if someone with a little HCL experience from the community is interested in implementing it, this might be a good issue for them to try.