Merge pull request #3351 from mitchellh/kikitux-doc-home-var

Add note for $HOME and ~
This commit is contained in:
Chris Bednarski 2016-03-14 10:36:19 -07:00
commit 7ac30135fc
1 changed files with 25 additions and 0 deletions

View File

@ -90,6 +90,10 @@ only within default values for user variables, user variables remain as the
single source of input to a template that a user can easily discover using
`packer inspect`.
-> **Why can't I use `~` for home variable?** `~` is an special variable
that is evaluated by shell during a variable expansion. As packer doesn't run
inside a shell, it won't expand `~`.
## Setting Variables
Now that we covered how to define and use variables within a template, the next
@ -162,3 +166,24 @@ provisioner only run if the `do_nexpose_scan` variable is non-empty.
"command": "if [ ! -z \"{{user `do_nexpose_scan`}}\" ]; then python -u trigger_nexpose_scan.py; fi"
}
```
## Using HOME Variable
In order to use `$HOME` variable, you can create a `home` variable in packer:
``` {.javascript}
"variables" {
"home": "{{env `HOME`}}"
}
```
And this will be available to be used in the rest of the template, ie:
``` {.javascript}
{
"builders": [{
"type":"google",
"account_file": "{{ user `home` }}/.secrets/gcp-{{ user `env` }}.json"
}]
}
```