#navi_header|技術| Vagrantの利用は、以下のような魔法のコマンドを叩くところから始まります。 vagrant init hashicorp/precise64 この時、裏側では"Vagrant Cloud"からBoxファイルをダウンロードしています。 "Vagrant Cloud"はBoxファイルをダウンロードするための共有リポジトリとして利用できます。また、今回は試してませんが"Vagrant Share"をするときもVagrant Cloudへのログインアカウントが必要だったりします。 今回は、 [[1302]] で作成したCentOSのイメージをVagrant Cloudで公開してみました。 - Vagrant Cloud -- https://vagrantcloud.com/ * 無料利用枠と有料でできること - 無料利用枠、有料サービス -- https://vagrantcloud.com/pricing Vagrant Cloudは無料でも使えますが、いくつか制限があります。有料版を使うことで、それらの制限を解除して、企業内のクローズドな開発体制にマッチした機能が利用できます。 - 有料であればprivateなboxを限定公開したり、Boxファイルのアップロードが可能になる。 - ※無料だとpublicオンリーで、Boxファイルはインターネット上のどこかのサイトに自分で配置してそのURLを登録する形になる。 * "Vagrant Share"とはどう違うのか? Vagrang CloudがWeb上のサービスであるのに対し、"Vagrant Share"はあくまでもクライアント側の機能になります。 今回は試してないので認識が間違ってるかもしれませんが、SSHのトンネリングなどを駆使して、ローカル上で起動しているVagrantのVMに対してインターネットからHTTP(S)でVM上のHTTPサーバにアクセスしたり、LAN内の他のマシンからSSHで接続できるようにするための機能と認識してます。 - Vagrant Cloud 入門 – Vagrant Share とは? | WEB ARCH LABO -- http://weblabo.oscasierra.net/vagrant-share/ - Vagrant Share - Vagrant Documentation -- http://docs.vagrantup.com/v2/share/index.html * 実際に公開してみたBoxファイルと参考URL まずは参考URL: - Vagrant Cloudでboxを公開してみた - @znz blog -- http://blog.n-z.jp/blog/2014-07-21-vagrantcloud-box.html - Vagrant CloudにBoxを公開する - Qiita -- http://qiita.com/y-mori/items/529a3a61903e7c80bad6 そんなに複雑な登録作業では無いです。無料利用枠ではVagrant Cloud自体にBoxファイルをアップロードすることは出来ませんので、外部のWebサーバにBoxファイルを配置し、そのURLをVagrant Cloud側に登録する必要があります。 Range機能が使えないWebサーバは対応していない、というような情報も見かけましたので、Vagrantクライアントが直接そのURLからDLするのではなく、Vagrant Cloudが間に入って中継しているのかもしれません。 今回は [[1302]] で作成したboxファイルをAmazon S3にアップして一般公開し、そのURLを登録しました。 ということで今回公開してみたBoxファイルです: https://vagrantcloud.com/msakamoto-sf/centos65-minimal-desktop * 公開したBoxファイルを使ってみる ↑のVagrant Cloudのページで、"vagrant init"コマンドの例が表示されてますので、そのままコピペすればOKです。 #pre||> > vagrant init msakamoto-sf/centos65-minimal-desktop A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. ||< まだこの時点ではBoxファイルのダウンロードは発生しません。"vagrant up"すると、自動的にダウンロードが始まります。 #pre||> > vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'msakamoto-sf/centos65-minimal-desktop' could not be found. Attempting to find and install... default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'msakamoto-sf/centos65-minimal-desktop' default: URL: https://vagrantcloud.com/msakamoto-sf/centos65-minimal-desktop ==> default: Adding box 'msakamoto-sf/centos65-minimal-desktop' (v0.1.0) for provider: virtualbox default: Downloading: https://vagrantcloud.com/msakamoto-sf/centos65-minimal-desktop/version/1/provider/virtualbox.b ox default: Progress: 100% (Rate: 5066k/s, Estimated time remaining: --:--:--) ==> default: Successfully added box 'msakamoto-sf/centos65-minimal-desktop' (v0.1.0) for 'virtualbox'! ==> default: Importing base box 'msakamoto-sf/centos65-minimal-desktop'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'msakamoto-sf/centos65-minimal-desktop' is up to date... ==> default: Setting the name of the VM: centos65_md_demo ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Connection timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => C:/work/tmp/vagrant_ex/t7 ||< 以下のディレクトリが作成され、圧縮状態のvmdk, metadata.json, Vagrantfile, box.ovf が展開されます。 $HOME/.vagrant.d/boxes/msakamoto-sf-VAGRANTSLASH-centos65-minimal-desktop/0.1.0/virtualbox * リモートからBoxファイルをDLさせるには、Vagrant Cloudしか使えないのか?LAN内で立ちあげたWebサーバからはDLできないのか? 今回は試してませんが、"vagrant init" コマンド、および "vagrant box add" コマンドではURLを指定できますので、LAN内で立ちあげたWebサーバからBoxファイルをDLすることは十分可能と思われます。 ※もしかしたら "vagrant init" の場合と "vagrant box add" の場合とでURLを指定した時の動きの中身は違うかも。 - "vagrant box add" では、Boxファイルを直接DLするURLを指定できるようですので、これならLAN内でも使えるかも。 -- http://docs.vagrantup.com/v2/cli/box.html - "vagrant init" でも "box-url" というのがありますが、"vagrant box add"で指定できるURLと意味的に同じかどうかはすぐには分かりませんでした。 -- http://docs.vagrantup.com/v2/cli/init.html #navi_footer|技術|