memo.xight.org

日々のメモ

Macで vagrant + vagrant cloud

Summary

1. vagrant 1.5以降にupgrade
2. vagrant cloudのアカウント作成
3. vagrant cloudにログイン
4. vagrant cloudのboxをaddする

vagrant 1.5 以降にupgrade

% brew cask install vagrant

% vagrant -v
Vagrant 1.6.3

% vagrant plugin list
vagrant-login (1.0.1, system)
vagrant-share (1.1.0, system)

vagrant cloud のアカウント作成

vagrant cloud からアカウント作成


vagrant cloud にログイン

% vagrant login
In a moment we'll ask for your username and password to Vagrant Cloud.
After authenticating, we will store an access token locally. Your
login details will be transmitted over a secure connection, and are
never stored on disk locally.

If you don't have a Vagrant Cloud account, sign up at vagrantcloud.com

Username or Email: YOUR USERNAME
Password (will be hidden):
You're now logged in!

vagrant cloud の boxを追加

% vagrant box add chef/debian-7.4
vagrant box add chef/debian-7.4
==> box: Loading metadata for box 'chef/debian-7.4'
	box: URL: https://vagrantcloud.com/chef/debian-7.4
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) virtualbox
2) vmware_desktop

Enter your choice: 1
==> box: Adding box 'chef/debian-7.4' (v1.0.0) for provider: virtualbox
	box: Downloading: https://vagrantcloud.com/chef/debian-7.4/version/1/provider/virtualbox.box
==> box: Successfully added box 'chef/debian-7.4' (v1.0.0) for 'virtualbox'!

vagrant up する

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "chef/debian-7.4"
  config.vm.box_url = "https://vagrantcloud.com/chef/debian-7.4/version/1/provider/virtualbox.box"

  config.vm.network :forwarded_port, guest: 80, host: 8080
  config.vm.provision "shell", inline: <<-EOT
	aptitude update
	apt-get install -y apache2
	rm -rf /var/www
	ln -fs /vagrant /var/www
	echo "<h1>Hello, Vagrant Cloud.</h1>" > /vagrant/index.html
  EOT
end


% vagrant up

Reference

わすれっぽいきみえ - 2014-04-05 - vagrantのboxをvagrant cloudからもらってくる
http://kimikimi714.hatenablog.com/entry/2014/04/05

Qiita - Mac OS XでVagrantとChefを使った環境構築のまとめ
http://qiita.com/hamichamp/items/e27a0ecacc33482936c8