I have gone through every iteration of this I can think of. My goal is to access variables from a Packer build script from in a provisioner shell script file.
variable "test" {
type = string
default = "testing123"
}
provisioner "shell" {
environment_vars = [
"TEST=${var.test}",
]
script = "./provisioners/script.sh"
execute_command = "echo "test:$TEST - ${var.test}; echo 'pw' | sudo -S bash -c '{{ .Path }}'"
}
}
The end result is an output of test: - testing123 for the first echo. If I add export TEST=${var.test} then the output is test: testing123 - testing123. However, in the script I can not see the values. Running printenv does not list them.
What is the best way to use values from build script in the provisioner shell script?