You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/website/content/partials/from-1.5/contextual-source-variables...

41 lines
895 B

## Source Variables
Use the following syntax to access the `name` and `type` of your `source` from provisioners and post-processors:
```
<build-name>.<source-type>.<source-name>
```
The following example queries source names used in the build:
```hcl
source "null" "first-example" {
communicator = "none"
}
build {
name = "roles"
source "null.first-example" {
name = "consul"
}
source "null.first-example" {
name = "nomad"
}
source "null.first-example" {
name = "vault"
}
sources = ["null.first-example"]
provisioner "shell-local" {
inline = ["echo ${source.name} and ${source.type}"]
}
}
```
The example returns the following values:
- `roles.null.consul`: Returns `consul` and `null`
- `roles.null.nomad`: Returns `nomad` and `null`
- `roles.null.vault`: Returns `vault` and `null`
- `roles.null.first-example`: Returns `first-example` and `null`