OS X, Vagrant, and Parallels Desktop. Build your boxes with veewee

  • Tutorial
In this article, I want to share my experience in creating my Vagrant boxes in OS X with the Parallels Desktop virtualization system. If there is interest, welcome under cut.



About Vagrant and Chef finally arrived had a good post: Development Environment using Vagrant and Chef .

However, if you, like me, use Parallels Desktop, a problem arises. The fact is that Parallels and VirtualBox cannot be started simultaneously. Therefore, you can use the vagrant-parallels virtual machine provider .

The installation and use procedure is described in some detail on the plugin page on Github, but I will duplicate the process just in case.

Personally, I use Homebrew to install various useful applications - we will use it.

eric@Copoka-3 ~> brew tap phinze/cask
eric@Copoka-3 ~> brew cask install vagrant
eric@Copoka-3 ~> vagrant plugin install vagrant-parallels

In general, everything is ready for work. The little thing is missing - the actual boxes. There is a link to devbox on the site with the plugin, but we want something more diverse and ours.

And then veewee enters the scene . Unfortunately, there is no ready-made veewee package, so we will build it ourselves.

In order not to clog the system with unnecessary gems, install rvm :

eric@Copoka-3 ~> \curl -sSL https://get.rvm.io | bash -s stable
eric@Copoka-3 ~> rvm install 2.1.0
eric@Copoka-3 ~> rvm use 2.1.0


Ruby is ready. Now actually veewee:

eric@Copoka-3 ~> cd Work
eric@Copoka-3 ~/Work> git clone https://github.com/jedi4ever/veewee.git
eric@Copoka-3 ~/Work> cd veewee
eric@Copoka-3 ~/W/veewee> rvm use 2.1.0@veewee --create 
eric@Copoka-3 ~/W/veewee> gem install bundler --no-ri --no-rdoc
eric@Copoka-3 ~/W/veewee> bundle install
eric@Copoka-3 ~/W/veewee> rake install


Now, to start creating boxes, you need to install the Parallels SDK by downloading it via the SDK link. You have downloaded
, installed, and you can proceed.

eric@Copoka-3 ~> cd Work
eric@Copoka-3 ~/Work> mkdir boxes
eric@Copoka-3 ~/Work> cd boxes


To create a box, it is proposed to use the template. The list of templates can be obtained like this:

eric@Copoka-3 ~/W/boxes> veewee parallels templates


The list is quite large, I will not give. For our purposes, we will use the good old Ubuntu 12.04 LTS:

eric@Copoka-3 ~/W/boxes> veewee parallels define 'precise64' 'ubuntu-12.04.3-server-amd64' 


Next, we are invited to start the assembly team veewee parallels build, but we will fail. Although, it would seem, we used a template for working with parallels, this template tries to install guest tools for VirtualBox and VMWare, but does not know anything about Parallels. Fix this flaw:

eric@Copoka-3 ~/W/boxes> cd definitions/precise64/
eric@Copoka-3 ~/W/b/d/precise64>


Here it is necessary to create a file parallels.shwith the following contents (I spied in the template for ubuntu-13.10-server-amd64, but there is another problem, I'll tell you later):

# Install the Parallels Tools
PARALLELS_TOOLS_ISO=prl-tools-lin.iso
mount -o loop $PARALLELS_TOOLS_ISO /media/cdrom
/media/cdrom/install --install-unattended-with-deps --progress
umount /media/cdrom


Then we edit definition.rb, remove from the list of postinstall_filesmentions about virtualbox and vmfusion, and add parallels.sh.
Now you can proceed:

eric@Copoka-3 ~/W/b/d/precise64> cd ../..
eric@Copoka-3 ~/W/boxes> veewee parallels build precise64


You can go have lunch, the process is quite lengthy. In the end, everything will end happily and we will see something like the following:

...много-много букв...
The box precise64 was built successfully!
You can now login to the box with:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 -l vagrant 10.211.55.7
eric@Copoka-3 ~/W/boxes> 


At this stage, you can go to the machine (password vagrant), make sure that everything is fine, add something (for example, Russian support). After we make sure that everything is installed as it should, you can pack it in a box for Vagrant.
But here one more pitfall awaits us. When trying to export, we get the following error:

Error: We executed a shell command and the exit status was not 0
- Command: prl_disk_tool compact --buildmap --hdd /Users/eric/Documents/Parallels/precise64.pvm/harddisk.hdd.
- Exitcode: 2.
- Output:
Operation progress 5% Unable to compact the disk.


This is a known error ; to solve it, you need to comment out a line optimize_diskin the file gems/veewee-0.3.12/lib/veewee/provider/parallels/box/export.rb(relative to the version of gemset used) - I had it 69th line.

After that, the export will work normally, and in the current directory we will see our treasured box:

eric@Copoka-3 ~/W/boxes> ll
total 1252512
drwxr-xr-x+ 3 eric  staff   102B 20 фев 17:44 definitions
drwxr-xr-x+ 4 eric  staff   136B 20 фев 17:39 iso
-rw-r--r--+ 1 eric  staff   612M 20 фев 18:46 precise64.box
eric@Copoka-3 ~/W/boxes> 


Add it to the piggy bank:

eric@Copoka-3 ~/W/boxes> vagrant box add 'precise64' '/Users/eric/Work/boxes/precise64.box'


Now we select a place for a test run and start the resulting box:

eric@Copoka-3 ~/W/boxes> cd ~/Work
eric@Copoka-3 ~/Work> mkdir testbox
eric@Copoka-3 ~/Work> cd testbox
eric@Copoka-3 ~/W/testbox> vagrant init precise64
eric@Copoka-3 ~/W/testbox> vagrant up --provider=parallels
eric@Copoka-3 ~/W/testbox> vagrant ssh
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.8.0-29-generic x86_64)
 * Documentation:  https://help.ubuntu.com/
Last login: Thu Feb 20 18:33:11 2014 from 10.211.55.2
vagrant@precise64:~$ 


What they wanted to get.

Now about Ubuntu 13.10. There, the template practically does not require changes, you just need to definition.rbuncomment the line for Parallels and, accordingly, comment out VirtualBox. Then everything is exactly the same.

However, when trying to make vagrant upour mailbox from 13.10, a timeout occurs waiting for the machine to start, although the machine starts successfully. This is due to a Parallels driver error for Linux. Parallels is aware of this error and promises to fix it in the next update. You can read about it on the vagrant-parallels issue tracker.

As a temporary solution, at the time of launch, it is proposed to help vagrant with your hands: enter the machine from the console and restart dhclient on eth0.

I hope my somewhat messy notes will be useful to someone, and will save time.

Also popular now: