diff --git a/website/content/guides/hcl/variables.mdx b/website/content/guides/hcl/variables.mdx index 979db040a..c32b2fc91 100644 --- a/website/content/guides/hcl/variables.mdx +++ b/website/content/guides/hcl/variables.mdx @@ -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 .