From edcc0b3853faa0ab0f940415fd05e23b109a936a Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 17 Jul 2018 18:49:36 +0300 Subject: [PATCH 1/2] shell-local: expose PACKER_HTTP_ADDR env var --- common/shell-local/run.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/shell-local/run.go b/common/shell-local/run.go index 51bb047b0..ede99e30d 100644 --- a/common/shell-local/run.go +++ b/common/shell-local/run.go @@ -9,6 +9,7 @@ import ( "sort" "strings" + "github.com/hashicorp/packer/common" commonhelper "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" @@ -165,6 +166,12 @@ func createFlattenedEnvVars(config *Config) (string, error) { envVars["PACKER_BUILD_NAME"] = fmt.Sprintf("%s", config.PackerBuildName) envVars["PACKER_BUILDER_TYPE"] = fmt.Sprintf("%s", config.PackerBuilderType) + // expose PACKER_HTTP_ADDR + httpAddr := common.GetHTTPAddr() + if httpAddr != "" { + envVars["PACKER_HTTP_ADDR"] = fmt.Sprintf("%s", httpAddr) + } + // interpolate environment variables config.Ctx.Data = &EnvVarsTemplate{ WinRMPassword: getWinRMPassword(config.PackerBuildName), From 221761d97acda4e185c4a5cf730d0cfb9ca758fa Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 17 Jul 2018 18:50:40 +0300 Subject: [PATCH 2/2] shell-local: add docs for PACKER_HTTP_ADDR env var --- website/source/docs/provisioners/shell-local.html.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/source/docs/provisioners/shell-local.html.md b/website/source/docs/provisioners/shell-local.html.md index d64e19fac..16719f239 100644 --- a/website/source/docs/provisioners/shell-local.html.md +++ b/website/source/docs/provisioners/shell-local.html.md @@ -184,6 +184,13 @@ commonly useful environmental variables: machine that the script is running on. This is useful if you want to run only certain parts of the script on systems built with certain builders. +- `PACKER_HTTP_ADDR` If using a builder that provides an http server for file + transfer (such as hyperv, parallels, qemu, virtualbox, and vmware), this + will be set to the address. You can use this address in your provisioner to + download large files over http. This may be useful if you're experiencing + slower speeds using the default file provisioner. A file provisioner using + the `winrm` communicator may experience these types of difficulties. + ## Safely Writing A Script Whether you use the `inline` option, or pass it a direct `script` or `scripts`,