From 279555b8e1aec7a7944ae17d46a8967ebdd6d7ad Mon Sep 17 00:00:00 2001 From: Dan Sedlacek Date: Thu, 29 Oct 2015 11:24:20 -0700 Subject: [PATCH 1/2] Added ability to see what SSH Port packer generated in template data --- builder/qemu/step_run.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 74db88a15..f6697d567 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -19,11 +19,12 @@ type stepRun struct { } type qemuArgsTemplateData struct { - HTTPIP string - HTTPPort uint - HTTPDir string - OutputDir string - Name string + HTTPIP string + HTTPPort uint + HTTPDir string + OutputDir string + Name string + SSHHostPort uint } func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction { @@ -148,6 +149,7 @@ func getCommandArgs(bootDrive string, state multistep.StateBag) ([]string, error config.HTTPDir, config.OutputDir, config.VMName, + sshHostPort, } newQemuArgs, err := processArgs(config.QemuArgs, &ctx) if err != nil { From 01462940954682e9ba539f8b8c3705740d910cb7 Mon Sep 17 00:00:00 2001 From: Dan Sedlacek Date: Sun, 7 Feb 2016 18:55:35 -0800 Subject: [PATCH 2/2] Added documentation --- .../source/docs/builders/qemu.html.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/website/source/docs/builders/qemu.html.markdown b/website/source/docs/builders/qemu.html.markdown index 7f1d9573c..366913189 100644 --- a/website/source/docs/builders/qemu.html.markdown +++ b/website/source/docs/builders/qemu.html.markdown @@ -253,6 +253,25 @@ builder and not otherwise conflicting with the qemuargs):
   qemu-system-x86 -m 1024m --no-acpi -netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device virtio-net,netdev=mynet0"
 
+ +You can also use the `SSHHostPort` template variable to produce a packer +template that can be invoked by `make` in parallel: + +``` {.javascript} + // ... + "qemuargs": [ + [ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"], + [ "-device", "virtio-net,netdev=forward,id=net0"], + ... + ] + // ... +``` +`make -j 3 my-awesome-packer-templates` spawns 3 packer processes, each of which +will bind to their own SSH port as determined by each process. This will also +work with WinRM, just change the port forward in `qemuargs` to map to WinRM's +default port of `5985` or whatever value you have the service set to listen on. + + - `shutdown_command` (string) - The command to use to gracefully shut down the machine once all the provisioning is done. By default this is an empty string, which tells Packer to just forcefully shut down the machine.