Merge pull request #3190 from mitchellh/f-qemu-ssh-port
Expose QEMU SSH port to templates
This commit is contained in:
commit
e920ad25bf
|
@ -19,11 +19,12 @@ type stepRun struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type qemuArgsTemplateData struct {
|
type qemuArgsTemplateData struct {
|
||||||
HTTPIP string
|
HTTPIP string
|
||||||
HTTPPort uint
|
HTTPPort uint
|
||||||
HTTPDir string
|
HTTPDir string
|
||||||
OutputDir string
|
OutputDir string
|
||||||
Name string
|
Name string
|
||||||
|
SSHHostPort uint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction {
|
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.HTTPDir,
|
||||||
config.OutputDir,
|
config.OutputDir,
|
||||||
config.VMName,
|
config.VMName,
|
||||||
|
sshHostPort,
|
||||||
}
|
}
|
||||||
newQemuArgs, err := processArgs(config.QemuArgs, &ctx)
|
newQemuArgs, err := processArgs(config.QemuArgs, &ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -253,6 +253,25 @@ builder and not otherwise conflicting with the qemuargs):
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
qemu-system-x86 -m 1024m --no-acpi -netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device virtio-net,netdev=mynet0"
|
qemu-system-x86 -m 1024m --no-acpi -netdev user,id=mynet0,hostfwd=hostip:hostport-guestip:guestport -device virtio-net,netdev=mynet0"
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
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
|
- `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
|
machine once all the provisioning is done. By default this is an empty
|
||||||
string, which tells Packer to just forcefully shut down the machine.
|
string, which tells Packer to just forcefully shut down the machine.
|
||||||
|
|
Loading…
Reference in New Issue