New to Packer : Help with building Virtual box VM image

86 views
Skip to first unread message

Ameya Karkhanis

unread,
Sep 13, 2016, 8:22:49 PM9/13/16
to Packer
Hi 
I am using packer to build a Virtual box image running 64bit ubuntu 14.04.4 server. My use case is when users import this image by default their networking is set to Bridged mode and the option to reinitialize mac address be set. 
I tried to enforce that in my template.json as below:

Is there a way to enforce this when the off file is built? 
Is this virtual box specific issue? Should I try this with VMware?

Any help is much appreciated. 

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "boot_command": [
        "<esc><wait>",
        "<esc><wait>",
        "<enter><wait>",
        "/install/vmlinuz<wait>",
        " auto<wait>",
        " console-setup/ask_detect=false<wait>",
        " console-setup/layoutcode=us<wait>",
        " console-setup/modelcode=pc105<wait>",
        " debian-installer=en_US<wait>",
        " fb=false<wait>",
        " initrd=/install/initrd.gz<wait>",
        " kbd-chooser/method=us<wait>",
        " keyboard-configuration/layout=USA<wait>",
        " keyboard-configuration/variant=USA<wait>",
        " locale=en_US<wait>",
        " netcfg/get_hostname=ubuntu-1404<wait>",
        " netcfg/get_domain=vm<wait>",
        " noapic<wait>",
        " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
        " -- <wait>",
        "<enter><wait>"
      ],
      "boot_wait": "10s",
      "disk_size": 40960,
      "guest_os_type": "Ubuntu_64",
      "http_directory": "http",
      "iso_checksum": "2ac1f3e0de626e54d05065d6f549fa3a",
      "iso_checksum_type": "md5",
      "ssh_username": "***",
      "ssh_password": "***",
      "ssh_port": 22,
      "ssh_wait_timeout": "10000s",
      "shutdown_command": "echo 'shutdown -P now' > /tmp/shutdown.sh; echo '***'|sudo -S sh '/tmp/shutdown.sh'",
      "vboxmanage": [
        [
          "modifyvm",
          "{{.Name}}",
          "--memory",
          "1024"
        ],
        [
          "modifyvm",
          "{{.Name}}",
          "--cpus",
          "1"
      ],
      [
          "modifyvm",
          "{{.Name}}",
          "--usb",
          "on"
      ],
      [
          "modifyvm",
          "{{.Name}}",
          "--nic0",
          "bridged"
      ],
      [
          "modifyvm",
          "{{.Name}}",
          "--macaddress0",
          "auto"
      ]
      ]
    }
],
"provisioners": [
    {
     "type": "shell",
     "execute_command": "echo '***'|sudo -E -S sh '{{.Path}}'",
     "override": {
       "virtualbox-iso": {
         "scripts": [
            "scripts/base.sh",
            "scripts/virtualbox.sh",
            "scripts/some_custom_scripts.sh",
            "scripts/cleanup.sh",
            "scripts/zerodisk.sh"
         ]
       }
     }
   }
 ]
}

Alvaro Miranda Aguilera

unread,
Sep 14, 2016, 3:13:30 AM9/14/16
to packe...@googlegroups.com
Hello

you have 3 vbox manage options.

for the vm when created used for packer
for vm changes before export


There is an export/import that Packer does that reset many values to default

So, you can add a copy or move those nic changes to :
vboxmanage_post (array of array of strings) - Identical to vboxmanage, except that it is run after the virtual machine is shutdown, and before the virtual machine is exported.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/e8bf8e0f-a520-4d4d-8d53-e657ac2ba6de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages