vmware-iso: My ISO image shuts down after installing, need to reboot and type commands

731 views
Skip to first unread message

Ray Bond

unread,
Aug 26, 2015, 11:30:04 PM8/26/15
to Packer
Hi,

I was able to configure Packer to install my company's custom ISO in a VM on ESX 6.0. After the install finishes, the VM shuts down. Meanwhile, I set the boot_delay to 30 minutes. After the 30 minutes, Packer errors out and unregisters the VM because it cannot connect via SSH.

I need Packer to do the following
  1. Prevent the VM from shutting down after installing from ISO OR boot up the VM after it shuts down
  2. Once the login prompt appears, the VM asks to login as root and immediately runs a script to install the application. I need Packer to login as root and then send it 30 to 40 more commands to finish the installation.
  3. Then I need to make Packer leave the VM running.

Is the above possible? What would be the best method of completing the above?


Also, unsure of why the SSH access is mandatory since the IP isn't set on the machine


Thank you,

R

R Bond

unread,
Aug 27, 2015, 2:05:08 AM8/27/15
to Packer
From this post it seems that Packer will create a template if completed successfully. 

I'm envisioning the following steps using Packer
  1. Install the ISO with a modified ks that forces the VM to reboot after installing from ISO
  2. Make the boot_wait long enough to get to the login prompt
  3. Pass in the commands using packer's boot_command array of strings
  4. Wait until application finishes installing
  5. Packer will then shutdown (hopefully successfully)
Then I can use vmrun to boot the image and then run the automated tests for the application.

What do you guys think? Any suggestions?

Alvaro Miranda Aguilera

unread,
Aug 27, 2015, 6:56:43 PM8/27/15
to packe...@googlegroups.com
Hello,

Packer build templates, so at somepoint it will expect turn the VM off.

Not sure if Packer is the tool you want to use for that task.

How long those VMs created from ISO are keep running? days? weeks?
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/4843968a-6bf7-4624-b7be-a6ae0e2997a6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Aug 27, 2015, 6:59:12 PM8/27/15
to packe...@googlegroups.com
Hello,

This one looks different to the previous.

You can use packer to create aVM with that iso and KS. Use
boot_commands is the way.

Then, you can use vagrant and one of the vpshere plugins to
start/create a VM from that VM and run those test as a provisioning
script.

This is the plugin I use and works very well:
https://github.com/nsidc/vagrant-vsphere

There is this other, but I haven't tested yet:
https://github.com/gosddc/vagrant-vcenter

Alvaro
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/e252ce94-9902-40cb-8d4e-4dea8cb7a4ab%40googlegroups.com.

R Bond

unread,
Aug 27, 2015, 10:52:01 PM8/27/15
to Packer
Ok. Thank you for your response.

Just to be sure, I'd have to append my current KS file to reboot, pass that file to packer with a long enough boot_delay to ensure that the iso installs and it gets to the login prompt, and then I can pass the boot_command commands to the vm to set up the vm.

If packer is still successful at this point, it will shutdown my vm and create an image that vagrant can easily launch. Now I can run tests on this ova once the vm boots up using vagrant.

It's too bad there isn't an option in packer to prevent the shutdown. If I could use such an option, I wouldn't even need vagrant cause I can start running tests immediately after I finish sending the boot commands.

Another method I'm exploring is using the ovftool to deploy powered off, echo vnc creds to vmk, vmrun or vim-cmd to boot the vm, then vncdo to send the vm commands. It works but man it's a preventable roundabout method.. :/

Chris Bednarski

unread,
Aug 28, 2015, 7:00:17 AM8/28/15
to packe...@googlegroups.com
It's too bad there isn't an option in packer to prevent the shutdown. If I could use such an option, I wouldn't even need vagrant cause I can start running tests immediately after I finish sending the boot commands.

You can run your tests using shell provisioners, and this can happen during one packer run. Likely you will need to extend some timeouts so you have enough time to run your tests.

Your config would look something like:

1. Builder to create the VM, add kickstart, boot command, etc.
2. shell provisioner(s) to setup your test environment
3. shell provisioner(s) to run your tests
4. (optional) file provisioner to download test results

If your test script exits 0/1 it should bubble up to packer as a build complete / build failed.

The potential weird thing you might run into is that when the build completes successfully packer will leave the new VM sitting somewhere. You will need a way to clean this up. There are many ways to do this. For example you can always exit 1 from your last provisioner to fail the build even if the tests pass. This way packer will clean up for you. But then you will need to pass the test success / fail status some other way.

Personally I would do this in two steps:

1. Create the base image with OS installed (longer time)
2. Clone this image to add code and run tests (shorter time)

This way tests run much more quickly. I don't think packer can clone in ESXi, though. I have used the Fusion VMX builder to do this and it works very well. The VMX clone step is very fast (seconds, not minutes).

--
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.
Reply all
Reply to author
Forward
0 new messages