only set PACKER_HTTP_ADDR if a server is listening
This commit is contained in:
parent
6563eb213c
commit
480398c3d2
|
@ -338,7 +338,10 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string, e
|
|||
// Always available Packer provided env vars
|
||||
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
||||
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
||||
envVars["PACKER_HTTP_ADDR"] = common.GetHTTPAddr()
|
||||
httpAddr := common.GetHTTPAddr()
|
||||
if httpAddr != "" {
|
||||
envVars["PACKER_HTTP_ADDR"] = httpAddr
|
||||
}
|
||||
|
||||
// Split vars into key/value components
|
||||
for _, envVar := range p.config.Vars {
|
||||
|
|
|
@ -232,9 +232,12 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
|||
envVars := make([]string, len(p.config.Vars)+3)
|
||||
envVars[0] = fmt.Sprintf("PACKER_BUILD_NAME='%s'", p.config.PackerBuildName)
|
||||
envVars[1] = fmt.Sprintf("PACKER_BUILDER_TYPE='%s'", p.config.PackerBuilderType)
|
||||
envVars[2] = fmt.Sprintf("PACKER_HTTP_ADDR=%s", common.GetHTTPAddr())
|
||||
|
||||
copy(envVars[3:], p.config.Vars)
|
||||
copy(envVars[2:], p.config.Vars)
|
||||
httpAddr := common.GetHTTPAddr()
|
||||
if httpAddr != "" {
|
||||
envVars = append(envVars, fmt.Sprintf("PACKER_HTTP_ADDR=%s", common.GetHTTPAddr()))
|
||||
}
|
||||
|
||||
for _, path := range scripts {
|
||||
ui.Say(fmt.Sprintf("Provisioning with shell script: %s", path))
|
||||
|
|
|
@ -294,7 +294,10 @@ func (p *Provisioner) createFlattenedEnvVars() (flattened string, err error) {
|
|||
// Always available Packer provided env vars
|
||||
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
||||
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
||||
envVars["PACKER_HTTP_ADDR"] = common.GetHTTPAddr()
|
||||
httpAddr := common.GetHTTPAddr()
|
||||
if httpAddr != "" {
|
||||
envVars["PACKER_HTTP_ADDR"] = httpAddr
|
||||
}
|
||||
|
||||
// Split vars into key/value components
|
||||
for _, envVar := range p.config.Vars {
|
||||
|
|
Loading…
Reference in New Issue