ページ

2014年1月9日

vagrant をparallels 9で使う方法とエラーが出たときの対象方法

VagrantをParallels 9で動作させる際のステップとトラブルが出た場合の対処方法です。

■デフォルトプロバイダーの環境変数を設定
$ export VAGRANT_DEFAULT_PROVIDER=parallels

1)SDKをダウンロード

こちらから、http://http://www.parallels.com/downloads/desktop/ 下記をダウンロード

 

2)bundlerインストール
# gem install bundler

または

$ sudo gem install bundler

3)veeweeインストール
$ git clone https://github.com/jedi4ever/veewee.git ./veewee
$ cd ./veewee
$ bundle install
Updating https://github.com/hh/em-winrm.git
Fetching gem metadata from http://rubygems.org/........
Fetching additional metadata from http://rubygems.org/.

.....

Your user account isn't allowed to install to the system Rubygems.

You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password

and install the bundled gems to Rubygems using sudo.

Password:

Using veewee (0.3.12) from source at .

Your bundle is complete!

Gems in the group kvm were not installed.

Use `bundle show [gemname]` to see where a bundled gem is installed.

4)define & Build
$ bundle exec veewee parallels define CentOS-6.5-min CentOS-6.5-x86_64-minimal
The basebox 'CentOS-6.5-min' has been successfully created from the template 'CentOS-6.5-x86_64-minimal'
You can now edit the definition files stored in ./Vagrant/veewee/definitions/CentOS-6.5-min or build the box with:

$ vi definitions/CentOS-6.5-min/definition.rb

(virtualbox.shをコメントアウト、vmfusion.shはコメントアウト済み)

     ...
"vagrant.sh",
#"virtualbox.sh",
#"vmfusion.sh",
"cleanup.sh",
...

(ファイルを編集する際に、ディレクトリをCentOS-6.5-min移動して、そこでビルドすると下記のようなエラーがでます



$ bundle exec veewee parallels build 'CentOS-6.5-min' --workdir=./Vagrant/veewee
Could not instantiate the box CentOS-6.5-min with provider Parallels ,definition 'CentOS-6.5-min' does not exist. Are you sure you are in the top directory?
definition 'CentOS-6.5-min' does not exist. Are you sure you are in the top directory?

$ cd ..

ビルド

$ bundle exec veewee parallels build 'CentOS-6.5-min' --workdir=./Vagrant/veewee
Building Box CentOS-6.5-min with Definition CentOS-6.5-min:
- debug : false
- cwd : /Volumes/WorkDisk/Vagrant/veewee
- force : false
- auto : false
- checksum : false
- postinstall_include : []
- postinstall_exclude : []

We did not find an isofile here : ./Vagrant/veewee/iso/CentOS-6.5-x86_64-minimal.iso.
The definition provided the following download information:
- Download url: http://yum.singlehop.com/CentOS/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso
- Md5 Checksum: 0d9dc37b5dd4befa1c440d2174e88a87

Download? (Yes/No) Yes
Creating an iso directory
...

dd: writing `/EMPTY': デバイスに空き領域がありません
30840+0 records in
30839+0 records out
32337432576 bytes (32 GB) copied, 434.936 s, 74.3 MB/s
The box CentOS-6.5-min was built successfully!
You can now login to the box with:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 -l veewee 10.211.55.10

$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 -l veewee 10.211.55.10

veewee@10.211.55.10's password:
Last login: Wed Jan  8 20:06:42 2014 from 10.211.55.2
Welcome to your Vagrant-built virtual machine.
[veewee@localhost ~]$

トラブル対処:CentOS-6.4-minのbuildでエラーが発生する場合
CentOS-6.5-minに変更します:

$ bundle exec veewee parallels build 'CentOS-6.4-min' --workdir=./Vagrant
Building Box CentOS-6.4-min with Definition CentOS-6.4-min:
- debug : false
- cwd : /Volumes/WorkDisk/Vagrant
- force : false
- auto : false
- checksum : false
- postinstall_include : []
- postinstall_exclude : []

We did not find an isofile here : ./veewee/iso/CentOS-6.4-x86_64-minimal.iso.
The definition provided the following download information:
- Download url: http://yum.singlehop.com/CentOS/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso
- Md5 Checksum: 4a5fa01c81cc300f4729136e28ebe600
Download? (Yes/No) Yes
Creating an iso directory<
Checking if isofile CentOS-6.4-x86_64-minimal.iso already exists.
Full path: /Users/yanagida/veewee/iso/CentOS-6.4-x86_64-minimal.iso
There was an error downloading http://yum.singlehop.com/CentOS/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso:
404 Not Found
$

なぜなら、そこにファイルは無いから・・・

http://yum.singlehop.com/CentOS/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso


5)Parallels Toolのインストール
GUIを動作させて、イメージの接続を解除する。

Parallels Toolのインストールを選択して、以下手動でマウント&インストール

# mkdir /mnt/dvd
# mount -o exec /dev/sr0 /mnt/dvd
# cd /mnt/dvd
# ./install

6)BOXの作成

$ bundle exec veewee parallels export 'CentOS-6.5-min'
Optimizing Disk
Error: We executed a shell command and the exit status was not 0
- Command :prl_disk_tool compact --buildmap --hdd ./Parallels/CentOS-6.5-min.pvm/harddisk.hdd.
- Exitcode :2.
- Output   :
Operation progress 5 %Unable to compact the disk.
Wrong exit code for command prl_disk_tool compact --buildmap --hdd ./Documents/Parallels/CentOS-6.5-min.pvm/harddisk.hdd

トラブル対処:exportでエラーが出た場合

export.rbを編集して対処します:

下記によるとKnown Issueで、2014/Janに変更予定らしいが・・・ワークアラウンドします。

"--buildmap"を消せということなので、消します:

https://github.com/yshahin/vagrant-parallels/issues/51

$ vi /veewee/lib/veewee/provider/parallels/box/export.rb

ここの178行目

optimize_command="#{@prldisktool} compact --buildmap --hdd #{path_to_hdd}"



optimize_command="#{@prldisktool} compact --hdd #{path_to_hdd}"

に変更する。
$ bundle exec veewee parallels export 'CentOS-6.5-min'
Optimizing Disk
Creating a temporary directory for export

Adding additional files
Creating Vagrantfile
Adding metadata.json file for Parallels Desktop provider
Exporting the box
Packaging the box
Cleaning up temporary directory
To import it into vagrant type:

vagrant box add 'CentOS-6.5-min' './veewee/CentOS-6.5-min.box'
To use it:
vagrant init 'CentOS-6.5-min'
vagrant up --provider=parallels
vagrant ssh

これで完成

トラブル対処:プラグインが見つからない場合
$ vagrant box add 'CentOS-6.5-min' './veewee/CentOS-6.5-min.box'
Failed to load the "vagrant-parallels" plugin. View logs for more details.

Downloading or copying the box...
Extracting box...te: 84.9M/s, Estimated time remaining: 0:00:01)

Successfully added box 'CentOS-6.5-min' with provider 'parallels'!

$
$ vagrant init CentOS-6.5-min
$ vagrant up

参考:https://github.com/yshahin/vagrant-parallels

プラグインのバージョンを合わせる必要があるらしい。

$ vagrant --version
Vagrant 1.3.5
$
$ vagrant plugin list
vagrant-parallels (0.0.9)
$

Version 1.4と1.3では使うプラグインが違うので、プラグインを入れ直し

$ vagrant plugin uninstall vagrant-parallels
$ vagrant plugin install vagrant-parallels --plugin-version 0.0.9