From 3450b6fd6f2dfdc043b4d8c55f8b6605d63cf588 Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 17 Jul 2018 17:03:05 +0300 Subject: [PATCH 1/2] ansible: expose packer_http_addr extra var --- provisioner/ansible/provisioner.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index d6e785c70..ae03284a6 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -336,6 +336,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...) From 430d9389bee1259f6cb16af4e6c4031156feccd8 Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 17 Jul 2018 17:15:35 +0300 Subject: [PATCH 2/2] website: add documentation for packer_http_addr extra variable --- website/source/docs/provisioners/ansible.html.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/source/docs/provisioners/ansible.html.md b/website/source/docs/provisioners/ansible.html.md index 26047458d..0096eaf22 100644 --- a/website/source/docs/provisioners/ansible.html.md +++ b/website/source/docs/provisioners/ansible.html.md @@ -142,6 +142,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.