mirror of
https://github.com/hashicorp/packer.git
synced 2026-05-28 04:35:38 -04:00
* allowing to set shell env vars from a key/value map. * tests This new map will work alongside the `environment_vars` but it allows using a datasource value seamlessly. At validation, and because `environment_vars` was an array of strings containing `KEY=value`, using datsources would not work, because these values are not known yet and would evaluate to `<unknown>`. With this, the value and the key can be unknown and will validate correctly for datasources.
39 lines
750 B
HCL
39 lines
750 B
HCL
|
|
data "null" "secret" {
|
|
input = "s3cr3t"
|
|
}
|
|
|
|
locals {
|
|
secret = data.null.secret.output
|
|
}
|
|
|
|
source "file" "foo" {
|
|
content = "foo"
|
|
target = "foo.txt"
|
|
}
|
|
|
|
build {
|
|
sources = ["file.foo"]
|
|
provisioner "shell-local" {
|
|
only_on = ["darwin", "freebsd", "linux", "openbsd", "solaris"]
|
|
# original bug in :
|
|
# environment_vars = ["MY_SECRET=${local.secret}"]
|
|
env = {
|
|
"MY_SECRET":"${local.secret}",
|
|
}
|
|
inline = [
|
|
"echo yo, my secret is $MY_SECRET",
|
|
"echo '' > $MY_SECRET",
|
|
]
|
|
}
|
|
provisioner "shell-local" {
|
|
only_on = ["windows"]
|
|
env = {
|
|
"MY_SECRET":"${local.secret}",
|
|
}
|
|
inline = [
|
|
"echo yo, my secret is %MY_SECRET%",
|
|
"echo '' > %MY_SECRET%",
|
|
]
|
|
}
|
|
}
|