diff --git a/template/interpolate/funcs.go b/template/interpolate/funcs.go index dfbaa9b50..4306b200e 100644 --- a/template/interpolate/funcs.go +++ b/template/interpolate/funcs.go @@ -44,7 +44,7 @@ var FuncGens = map[string]interface{}{ "consul_key": funcGenConsul, "vault": funcGenVault, "sed": funcGenSed, - "generated": funcGenGenerated, + "build": funcGenBuild, "replace": replace, "replace_all": replace_all, @@ -164,7 +164,7 @@ func funcGenTemplateDir(ctx *Context) interface{} { } } -func funcGenGenerated(ctx *Context) interface{} { +func funcGenBuild(ctx *Context) interface{} { return func(s string) (string, error) { if data, ok := ctx.Data.(map[interface{}]interface{}); ok { // PlaceholderData has been passed into generator, so if the given @@ -184,7 +184,7 @@ func funcGenGenerated(ctx *Context) interface{} { return "", fmt.Errorf("loaded data, but couldnt find %s in it.", s) } - return "", fmt.Errorf("Error validating computed variable: the given "+ + return "", fmt.Errorf("Error validating build variable: the given "+ "variable %s will not be passed into your plugin.", s) } } diff --git a/website/source/docs/templates/engine.html.md b/website/source/docs/templates/engine.html.md index 3391e4b77..f868669ef 100644 --- a/website/source/docs/templates/engine.html.md +++ b/website/source/docs/templates/engine.html.md @@ -62,22 +62,27 @@ Here is a full list of the available functions for reference. each function will behave. - `env` - Returns environment variables. See example in [using home variable](/docs/templates/user-variables.html#using-home-variable) -- `generated` - This engine will allow you to access special variables that +- `build` - This engine will allow you to access special variables that provide connection information and basic instance state information. Usage example: ```json { "type": "shell-local", - "environment_vars": ["TESTVAR={{ generated `PACKER_RUN_UUID`}}"], + "environment_vars": ["TESTVAR={{ build `PackerRunUUID`}}"], "inline": ["echo $TESTVAR"] }, ``` - Valid variables to request are: "ID", "Host", "Port", "User", "Password", - "ConnType", "PACKER_RUN_UUID", "SSHPublicKey", "SSHPrivateKey", and - "WinRMPassword", though obviously depending on which communicator you are - using, some of these values may be empty. ID represents the vm being - provisioned. For example, in Amazon it is the instance id; in digitalocean, - it is the droplet id; in Vmware, it is the vm name. + Valid variables to request are: "InstanceID", "CommunicatorHost", + "CommunicatorPort", "CommunicatorUser", "CommunicatorPassword", "ConnType", + "PackerRunUUID", "CommunicatorPublicKey", and "CommunicatorPrivateKey". + Depending on which communicator you are using, some of these values may be + empty -- for example, the public and private keys are unique to the SSH + communicator. InstanceID represents the vm being provisioned. For example, + in Amazon it is the instance id; in digitalocean, it is the droplet id; in + Vmware, it is the vm name. + + For backwards compatability, `WinRMPassword` is also available through this + engine, though it is no different than using the more general `Password`. This function is only for use within _provisioners_, and does not yet work if the provisioners are being used in conjunction with our chroot builders