Add details on the expected contents of a variable definitions file (#11403)

Closes #10903
pull/11406/head
Wilken Rivera 4 years ago committed by GitHub
parent 06b35c39de
commit 41e6f760d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -171,15 +171,19 @@ command line variables as strings.
#### From a file
To persist variable values, create a file and assign variables within
this file. Create a file named `variables.pkrvars.hcl` with the following
contents:
this file. A variable definitions file uses the same basic syntax as Packer language files,
but consists only of variable name assignments.
```hcl
sudo_password = "partyparrot"
weekday = "Sunday"
```
You tell Packer to use this var file using the `-var-file` command line flag.
When assigning values in a variable definitions file please make sure to quote any string values,
wrap list values within brackets `[...]`, and wrap maps within curly-braces `{...}`.
Given a file named `variables.pkrvars.hcl` Packer can be instructed to use the
variable definitions file by using the `-var-file` command line flag.
```shell-session
$ packer build -var-file="variables.pkrvars.hcl" .
@ -187,8 +191,8 @@ $ packer build -var-file="variables.pkrvars.hcl" .
Packer will automatically load any var file that matches the name
`*.auto.pkrvars.hcl`, without the need to pass the file via the command line.
if we rename the above var-file from variables.pkrvars.hcl to
variables.auto.pkrvars.hcl, then we can run our build simply by calling
If we rename the above variable definitions file from `variables.pkrvars.hcl` to
`variables.auto.pkrvars.hcl`, then we can run our build simply by calling
```shell-session
$ packer build .

Loading…
Cancel
Save