Vagrantでボックスの追加からvagrant initまでonlineですます

何かのテスト環境はほとんどVagrantで作るような状態が続いているとvagrant initしたあとにVagrantfileを編集するのがめんどくさくなってきたので、vagrant box add とvagrant init(最低限だけど)を同時にやる方法をみつけたのでその方法をメモっておく

vagrant initのヘルプ

vagrant initのヘルプを読んでみるとこんなコードが出てきた。

$ vagrant init --help
Usage: vagrant init [box-name] [box-url]
-h, --help                       Print this help

もしかしたら、いままでvagrant initしたあとにVagrantfileの = "base"


でも、うしろの[box-url]ってなんだろうと、vagrant box addで指定するboxのURLを指定してみたら

vagrant box add [box-name] [box-url]
vagrant init
vi Vagrantfile
vagrant up

vagrant init [box-name] [box-url]
vagrant up


vagrant init [box-name] [box-url]で 指定されたboxはvagrant up時にaddされる感じ。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'box-name' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading or copying the box...
Extracting box...te: 26.2M/s, Estimated time remaining: 0:00:01))
Successfully added box 'box-name' with provider 'virtualbox'!
[default] Importing base box 'box-name'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- /vagrant


入門Chef Solo - Infrastructure as Code
伊藤直也 (2013-03-11)
売り上げランキング: 143

Rlated & Feedbacks