📜 ⬆️ ⬇️

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

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



About Vagrant and Chef was already a good post: Development Environment with 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 virtual machine provider vagrant-parallels .

The procedure for installing and using 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 - and 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. There is not enough trivia - actually the boxes. On the site with the plugin there is a link to the devbox, but we also want something more diverse and different.

And here veewee comes on the scene. Unfortunately, there is no ready veewee package, so we will assemble it ourselves.

In order not to overload 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 mailboxes, you need to install the Parallels SDK by downloading it from the SDK link.
Download, install, you can proceed.

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


To create a box is invited to use the template. The list of templates can be obtained as follows:

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


The list is quite large, I will not give. For our purposes, let's 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 asked to start the build with the veewee parallels build , but we will fail. Although it would seem that we used a template for working with parallels, this template tries to install guest tools for VirtualBox and VMWare, but knows nothing about Parallels. Fix this flaw:

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


Here you need to create a parallels.sh file with the following content (I looked in the template for ubuntu-13.10-server-amd64, but there’s 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 edit definition.rb , remove virtualbox and vmfusion references from the postinstall_files list, 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 to dinner, the process is quite long. In the end, everything will be safely completed 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 ( vagrant password), make sure everything is fine, add something (for example, Russian support). After we make sure that everything is set as it should, you can pack it in a box for Vagrant.
But here we are waiting for another underwater rock. When trying to export, we get the following error:

 Error was not executed.
 - 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 the optimize_disk line in the gems/veewee-0.3.12/lib/veewee/provider/parallels/box/export.rb export.rb file (relative to the gemset version used) - I had it 69th line.

After that, the export will work properly, and in the current directory we will see our cherished 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 choose 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 any changes, you only need to uncomment the line for Parallels in definition.rb and, therefore, comment out VirtualBox. Then everything is exactly the same.

However, when trying to make a vagrant up our mailbox from 13.10, the machine waits for the machine to start, although the machine starts successfully. This is due to an error in the Parallels drivers for Linux. Parallels knows about this error and promises to fix it in the near update. You can read about it on the vagrant-parallels issue tracker.

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

I hope my somewhat chaotic notes will come in handy for someone, and allow me to save time.

Source: https://habr.com/ru/post/213351/


All Articles