diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index ead4d44b2..99c4d07d9 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -366,6 +366,13 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri // args = append(args, "--private-key", privKeyFile) args = append(args, "-e", fmt.Sprintf("ansible_ssh_private_key_file=%s", privKeyFile)) } + + // expose packer_http_addr extra variable + httpAddr := common.GetHTTPAddr() + if httpAddr != "" { + args = append(args, "--extra-vars", fmt.Sprintf("packer_http_addr=%s", httpAddr)) + } + args = append(args, p.config.ExtraArguments...) if len(p.config.AnsibleEnvVars) > 0 { envvars = append(envvars, p.config.AnsibleEnvVars...) diff --git a/website/source/docs/provisioners/ansible.html.md b/website/source/docs/provisioners/ansible.html.md index bf1145f64..890cc00b0 100644 --- a/website/source/docs/provisioners/ansible.html.md +++ b/website/source/docs/provisioners/ansible.html.md @@ -163,6 +163,13 @@ commonly useful Ansible variables: machine that the script is running on. This is useful if you want to run only certain parts of the playbook 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. + ## Debugging To debug underlying issues with Ansible, add `"-vvvv"` to `"extra_arguments"` to enable verbose logging.