Venkat Raman
Venkat Raman

Reputation: 103

Can Vagrant suffice my requirement?

I have been looking out for ways to setup an automation environment and I found this application named Vagrant. I read the docs on the site, however I wanted to know from the experts out there if Vagrant with Oracle VirtualBox would suffice my needs.

  1. I need to have a script that will call Vagrant to initialize a VM [The VM-Image is always the same - Windows Server 2008 R2]
  2. I need to copy some of my project related files from a shared location onto the VM
  3. Call a Batch file that will take care of test runs for me inside the VM
  4. Once my test run is complete, This VM needs to be self destroyed/destructed.

Also, I would like to know if the Image be a custom .ISO file?

Upvotes: 0

Views: 148

Answers (1)

Bill Agee
Bill Agee

Reputation: 3646

Sounds like Vagrant and VirtualBox will work for that scenario. Also, you might find that running commands in the VM using WinRM or SSH may be the easiest way to launch tests.

If you haven't already seen it, the blog post about Windows support in Vagrant 1.6 is informative: https://www.vagrantup.com/blog/feature-preview-vagrant-1-6-windows.html

Creating a VirtualBox/Vagrant base VM from an .iso should work, and you can then do all of your work using the VM from that point onward.

To get started, you might try these steps:

  • Create a VirtualBox VM from your Windows .iso, using the VirtualBox GUI or cmdline tools.
  • Once you have the VM in the state you want it, shut it down and package it as a vagrant box - for example, on a Mac that step looks like (where Win7x64 is the dir containing the VirtualBox VM):

    cd ~/VirtualBox\ VMs
    vagrant package --base Win7x64 --output win7x64_base.box
    
  • Once that finishes, tell vagrant about the new base box:

    vagrant box add win7x64_base /path/to/win7_base.box
    
  • Then you can vagrant init/vagrant up the VM:

    mkdir win7 && cd win7
    vagrant init win7x64
    vagrant up
    

To enable SSH access, I installed Cygwin in the VM and configured sshd. So, after launching you can SSH in by running vagrant ssh

Note that if there's no Windows user in the VM named 'vagrant', you can specify the SSH username to use with vagrant ssh by placing this in your Vagrantfile:

config.ssh.username = 'user1'

As mentioned above, WinRM is also an option for remotely running commands.

And Vagrant apparently has some convenience features to make it easy to RDP into the VM, but I haven't looked at that.

Upvotes: 2

Related Questions