how can do "VBoxManage modifyvm" operation before export vm ?

95 views
Skip to first unread message

JerryWang

unread,
Jan 24, 2018, 8:11:19 AM1/24/18
to Packer
 this steps should be done after provioner  ( and vm was poweroff ), where to put this operation ?  builder ? or  post-processor ?
thanks. 

Rickard von Essen

unread,
Jan 24, 2018, 9:03:36 AM1/24/18
to packe...@googlegroups.com

On Jan 24, 2018 14:11, "JerryWang" <qq93...@gmail.com> wrote:
 this steps should be done after provioner  ( and vm was poweroff ), where to put this operation ?  builder ? or  post-processor ?
thanks. 

--
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/fc2eb65c-4b39-4034-a48d-1abc99be9950%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JerryWang

unread,
Jan 24, 2018, 10:30:53 PM1/24/18
to Packer
thanks for your reply. 
this json can be working successfully,

      "vboxmanage"           : [
        [ "modifyvm", "{{.Name}}", "--memory", "{{user `memSize`}}"],
        [ "modifyvm", "{{.Name}}", "--cpus",   "{{user `cpuCount`}}" ],
        [ "modifyvm", "{{.Name}}", "--nic1", "nat"]
      ],

if i add  vboxmanage_post  like this,
     "vboxmanage_post": ["modifyvm", "{{.Name}}", "--nic1", "bridged"],
     
but when running the json, vboxmanage run failed, can you help to tell me what's the problem with my json file ?
my packer version is 1.1.3. 

from my point, after vm was poweroff, can {{.Name}} point to the new created vm ? 


the full json file is: 
{
  "description"              : "import a existing ova and pull image and then export to as a ova image",

  "variables"                : {
    "diskImg"                : "/vmimage/OMSP.ova",
    "vmName"                 : "OracleLinux7u4_vbox",
    "memSize"                : "2048",
    "cpuCount"               : "1",
    "diskSize"               : "36720",
    "diskFmt"                : "ova",
    "chefCookbooks"          : "cookbooks",
    "nicInterFace"           : "eno1",
    "chefRunlist"            : "recipe[httpd]"
  },

  "builders"                 : [{
      "type"                 : "virtualbox-ovf",
      "name"                 : "vboxOvfBuilder",
      "vboxmanage"           : [
        [ "modifyvm", "{{.Name}}", "--memory", "{{user `memSize`}}"],
        [ "modifyvm", "{{.Name}}", "--cpus",   "{{user `cpuCount`}}" ],
        [ "modifyvm", "{{.Name}}", "--nic1", "nat"]
      ],
     "vboxmanage_post": ["modifyvm", "{{.Name}}", "--nic1", "bridged"],
      "export_opts":
      [
      "--manifest",
      "--vsys", "0",
      "--description", "create vm with nat and then change to bridged",
      "--version", "2.0"
      ],
      "source_path"          : "{{user `diskImg`}}",
      "format"               : "{{user `diskFmt`}}",
      "headless"             : true,
      "vrdp_bind_address"    : "0.0.0.0",
      "ssh_host_port_min"    : 2222,
      "ssh_host_port_max"    : 2229,
      "output_directory"     : "images-{{timestamp}}",
      "communicator"         : "ssh",
      "ssh_port"             : 22,
      "ssh_username"         : "root",
      "ssh_password"         : "welcome1",
      "ssh_wait_timeout"     : "1500s",
      "vm_name"              : "oraclelinux7u4-vbox_bridge_1nat-{{timestamp}}",
      "shutdown_command"     : "shutdown -P now"
    }
  ],
  "provisioners": [{
      "type"                 : "shell",
      "script"               : "scripts/getimage.sh"
    }
  ]
}






On Wednesday, January 24, 2018 at 10:03:36 PM UTC+8, Rickard von Essen wrote:
On Jan 24, 2018 14:11, "JerryWang" <qq93...@gmail.com> wrote:
 this steps should be done after provioner  ( and vm was poweroff ), where to put this operation ?  builder ? or  post-processor ?
thanks. 

--
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...@googlegroups.com.

Rickard von Essen

unread,
Jan 25, 2018, 12:00:17 AM1/25/18
to packe...@googlegroups.com
What's the error message? 

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/591c3fd9-c030-41bd-84e2-8d67e9c18dbf%40googlegroups.com.

JerryWang

unread,
Jan 25, 2018, 12:21:59 AM1/25/18
to Packer

from the debug log info : 


2018/01/25 10:25:32 ui: ask: ==> vboxOvfBuilder: Pausing after run of step 'StepProvision'. Press enter to continue.
2018/01/25 10:25:43 ui: ==> vboxOvfBuilder: Gracefully halting virtual machine...
2018/01/25 10:25:43 packer: 2018/01/25 10:25:43 Executing shutdown command: shutdown -P now
2018/01/25 10:25:43 packer: 2018/01/25 10:25:43 opening new ssh session
2018/01/25 10:25:43 packer: 2018/01/25 10:25:43 starting remote command: shutdown -P now
2018/01/25 10:25:44 packer: 2018/01/25 10:25:44 Remote command exited without exit status or exit signal.
2018/01/25 10:25:44 packer: 2018/01/25 10:25:44 Waiting max 5m0s for shutdown to complete
2018/01/25 10:25:54 packer: 2018/01/25 10:25:54 VM shut down.
2018/01/25 10:25:54 ui: ask: ==> vboxOvfBuilder: Pausing after run of step 'StepShutdown'. Press enter to continue.
2018/01/25 10:26:41 ui: ask: ==> vboxOvfBuilder: Pausing after run of step 'StepRemoveDevices'. Press enter to continue.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2018/01/25 10:26:44 ui: ==> vboxOvfBuilder: Executing custom VBoxManage commands...
2018/01/25 10:26:44 ui:     vboxOvfBuilder: Executing: modifyvm
2018/01/25 10:26:44 packer: 2018/01/25 10:26:44 Executing VBoxManage: []string{"modifyvm"}
2018/01/25 10:26:44 packer: 2018/01/25 10:26:44 stdout: Usage:
2018/01/25 10:26:44 packer: 
2018/01/25 10:26:44 packer: VBoxManage modifyvm         <uuid|vmname>
2018/01/25 10:26:44 packer:                             [--name <name>]
2018/01/25 10:26:44 packer:                             [--groups <group>, ...]
2018/01/25 10:26:44 packer:                             [--description <desc>]
2018/01/25 10:26:44 packer:                             [--ostype <ostype>]
2018/01/25 10:26:44 packer:                             [--iconfile <filename>]
2018/01/25 10:26:44 packer:                             [--memory <memorysize in MB>]
2018/01/25 10:26:44 packer:                             [--pagefusion on|off]
2018/01/25 10:26:44 packer:                             [--vram <vramsize in MB>]
2018/01/25 10:26:44 packer:                             [--acpi on|off]
2018/01/25 10:26:44 packer:                             [--pciattach 03:04.0]
2018/01/25 10:26:44 packer:                             [--pciattach 03:04.0@02:01.0]
2018/01/25 10:26:44 packer:                             [--pcidetach 03:04.0]
2018/01/25 10:26:44 packer:                             [--ioapic on|off]
2018/01/25 10:26:44 packer:                             [--hpet on|off]
2018/01/25 10:26:44 packer:                             [--triplefaultreset on|off]
2018/01/25 10:26:44 packer:                             [--apic on|off]
2018/01/25 10:26:44 packer:                             [--x2apic on|off]
..........................................................................................................................

Rickard von Essen

unread,
Jan 25, 2018, 12:33:39 AM1/25/18
to packe...@googlegroups.com
You are missing on pair of [ ] in your vboxmanage_post command, it should be:

"vboxmanage_post": [
    ["modifyvm", "{{.Name}}", "--nic1", "bridged"]
],
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/b8ab4dfe-94c3-461e-8b93-2e08c2a769d7%40googlegroups.com.

JerryWang

unread,
Jan 25, 2018, 12:55:18 AM1/25/18
to Packer
great help for your support! 
is there any command or tool to check/find the syntax issue for the json file ?
I have tried fix/inspect/validate, no one works.

Rickard von Essen

unread,
Jan 25, 2018, 2:10:34 AM1/25/18
to packe...@googlegroups.com
Validate, but your error is not caught since it's valid.

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/f4090385-0668-4876-9160-653fc6d88d5a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages