Each argument need to be it's own string:
[ "modifyvm", "{{.Name}}", "--nic2", "hostonly --hostonlyadapter1 vboxnet1"
]

must be:
[ "modifyvm", "{{.Name}}", "--nic2", "hostonly", "--hostonlyadapter1",
"vboxnet1" ]

// Rickard

On Mon, Oct 15, 2018 at 10:26 AM steve BP <stevebpatw...@gmail.com> wrote:

> Hi
>
> I am using packer (Windows) to build and deploy virtual box VMs with
> Windows 2012 installations. This has worked very well for our automated
> deployment and test of control applications.
>
> I am trying to add a hostonly network interface as part of the virtual box
> builder and have run into errors.
>
> I wish to add the host-only interface in the builder, as opposed to a
> provisioner or post builder so that resources on the host only network can
> be used by the provisioners.
>
> My builder vboxmanage is as follows (full builder below)
>
>     "vboxmanage": [
>         [ "modifyvm", "{{.Name}}", "--natpf1", "winrm,tcp,,55985,,5985" ],
>         [ "modifyvm", "{{.Name}}", "--memory", "{{user
> `target_MemorySize`}}" ],
>         [ "modifyvm", "{{.Name}}", "--cpus", "{{user `target_Cpu`}}" ],
>         [ "modifyvm", "{{.Name}}", "--nic2", "hostonly --hostonlyadapter1
> vboxnet1" ]
>       ],
>
> Packer is responding as following with an error.
>
> I have tried the vboxmanage command from a shell and this works ok on a
> test vm, so think that my command syntax is ok.
>
> > vboxmanage modifyvm "C:\Users\sbp\VirtualBox VMs\hostTest"\hostTest.vbox
> --nic2 hostonly --hostonlyadapter1 vboxnet1
>
> Would anybody please be able to advise me how to make this feature work.
>
> Thanks in advance.
>
> Steve
>
> *Packer Output*
>
> E:\svn-mirror\projects\Home\Steve_Pinfold\PackerWindowsBuilder\branches\TLS-amd64>packer.exe
> build Output.json
> virtualbox-iso output will be in this color.
>
> ==> virtualbox-iso: Retrieving Guest additions
>     virtualbox-iso: Using file in-place:
> file:///C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
> ==> virtualbox-iso: Retrieving ISO
>     virtualbox-iso: Using file in-place:
> file:///E:/usr/tools/WindowsInstallers/SW_DVD5_WIN_PRO_7W_SP1_64BIT_ENGLISH_-2_MLF_X17-59279.ISO
> ==> virtualbox-iso: Creating floppy disk...
>     virtualbox-iso: Copying files flatly from floppy_files
>     virtualbox-iso: Copying file: AutoUnattend.xml
>     virtualbox-iso: Done copying files from floppy_files
>     virtualbox-iso: Collecting paths from floppy_dirs
>     virtualbox-iso: Resulting paths from floppy_dirs : []
>     virtualbox-iso: Done copying paths from floppy_dirs
> ==> virtualbox-iso: Creating virtual machine...
> ==> virtualbox-iso: Creating hard drive...
> ==> virtualbox-iso: Attaching floppy disk...
> ==> virtualbox-iso: Creating forwarded port mapping for communicator (SSH,
> WinRM, etc) (host port 2840)
> ==> virtualbox-iso: Executing custom VBoxManage commands...
>     virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1539588999
> --natpf1 winrm,tcp,,55985,,5985
>     virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1539588999
> --memory 2048
>     virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1539588999
> --cpus 2
>     virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1539588999
> --nic2 hostonly --hostonlyadapter1 vboxnet1
> ==> virtualbox-iso: Error executing command: VBoxManage error:
> VBoxManage.exe: error: Invalid type 'hostonly --hostonlyadapter1 vboxnet1'
> specfied for NIC 2
> ==> virtualbox-iso: Deregistering and deleting VM...
> ==> virtualbox-iso: Deleting output directory...
> Build 'virtualbox-iso' errored: Error executing command: VBoxManage error:
> VBoxManage.exe: error: Invalid type 'hostonly --hostonlyadapter1 vboxnet1'
> specfied for NIC 2
>
> ==> Some builds didn't complete successfully and had errors:
> --> virtualbox-iso: Error executing command: VBoxManage error:
> VBoxManage.exe: error: Invalid type 'hostonly --hostonlyadapter1 vboxnet1'
> specfied for NIC 2
>
> ==> Builds finished but no artifacts were created.
>
> *Full Builder*
>
>   "builders": [
>     {
>       "type": "virtualbox-iso",
>       "vboxmanage": [
>         [ "modifyvm", "{{.Name}}", "--natpf1", "winrm,tcp,,55985,,5985" ],
>         [ "modifyvm", "{{.Name}}", "--memory", "{{user
> `target_MemorySize`}}" ],
>         [ "modifyvm", "{{.Name}}", "--cpus", "{{user `target_Cpu`}}" ],
>     [ "modifyvm", "{{.Name}}", "--nic2", "hostonly --hostonlyadapter1
> vboxnet1" ]
>       ],
>       "vboxmanage_post": [
> [ "modifyvm", "{{.Name}}", "--nic1", "bridged", "--bridgeadapter1",
> "{{user `host_NetworkAdaptor`}}" ]
>   ],
>       "guest_os_type": "{{user `OS_Type`}}",
>       "iso_url": "{{user `OS_Iso`}}",
>       "iso_checksum": "{{user `Os_Checksum`}}",
>       "iso_checksum_type": "md5",
>       "disk_size": "{{user `target_DiskSize`}}",
>       "communicator": "winrm",
>       "winrm_username": "vagrant",
>       "winrm_password": "vagrant",
>       "winrm_port": "5985",
>       "winrm_timeout": "10h",
>       "guest_additions_mode": "attach",
>   "post_shutdown_delay": "3m",
>       "shutdown_command": "shutdown -s -t 3000",
>       "shutdown_timeout": "5h",
>       "floppy_files": [
>         "AutoUnattend.xml"
>       ],
>       "export_opts": [
> "--manifest",
>         "--vsys",
>         "0",
>         "--description",
>         "{{user `vm_description`}}",
>         "--version",
>         "{{user `vm_version`}}"
>       ]
>     }
>   ],
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/be5dcf72-efac-44c4-9cf0-317f2da5f445%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/be5dcf72-efac-44c4-9cf0-317f2da5f445%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to packer-tool+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9zE1O9hJy-Oe%3DnJZ6s6vSLjYPf0CwuoHY-eQeAd3aZpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to