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

HCL2 variables not parsed from environment #9622

Closed
valenvb opened this issue Dec 11, 2020 · 2 comments · Fixed by #9623
Closed

HCL2 variables not parsed from environment #9622

valenvb opened this issue Dec 11, 2020 · 2 comments · Fixed by #9623
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. type/bug

Comments

@valenvb
Copy link

valenvb commented Dec 11, 2020

Nomad version

Nomad v1.0.0 (cfca6405ad9b5f66dffc8843e3d16f92f3bedb43)

Operating system and Environment details

Ubuntu 18.04, tested in zsh 5.4.2 and bash 4.4.20

Issue

Using environment variables to define HCL2 variables (as described in the docs) does not work.

Running a job results in the following output:

$ nomad run test.nomad 
Error getting job struct: Error parsing job file from test.nomad:
<nil>: Unset variable "text"; A used variable must be set or have a default value; see https://packer.io/docs/configuration/from-1.5/syntax for details.

Reproduction steps

  1. Create a jobspec as below.
  2. set environment variable as described in the docs $ export NOMAD_VAR_text="hello"
  3. Run job: $ nomad run test.nomad

inline-ing the variable also does not work: $ NOMAD_VAR_text=hello nomad run test.nomad

Job file (if appropriate)

variable "text" {
  type  = string
}

job "repro" {
  datacenters = ["dc1"]
  type = "batch"
  group "repro" {

    task "a" {
      driver = "docker"
      config {
        image = "alpine:3"
        command = "echo"
        args = [ var.text ]
      }
    }
  }
}
@notnoop notnoop self-assigned this Dec 11, 2020
@notnoop notnoop added stage/accepted Confirmed, and intend to work on. No timeline committment though. type/bug labels Dec 11, 2020
@notnoop
Copy link
Contributor

notnoop commented Dec 11, 2020

Thanks @valenvb . That was a 🤦 bug. I've fixed the issue for 1.0.1, and removed the environment variables docs. I'm very sorry we didn't catch this earlier, but aiming to have a release out very soon.

@github-actions
Copy link

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 Oct 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants