mirror of
https://github.com/hashicorp/packer.git
synced 2026-10-15 02:33:01 -04:00
41 lines
895 B
Plaintext
41 lines
895 B
Plaintext
## 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` |