Vagrant 使ってみる
Vagrant は仮想環境をセットアップするためのショートカットみたいなもの。 Chef はサーバ環境に必要なソフトのセットアップ・設定を自動化するためのもの。
ホストに使ってるのは Ubuntu13.10
VirtualBox
vagrant 経由で使うのでインストール。
sudo apt-get install virtualbox
入ったのは 4.2.16 だった。4.3.x 以降は現時点で vagrant 側が対応していないので手は出さない。
vagrant
公式から deb パッケージ落として入れる。
ちなみにこの記事書いてる時点で最新が 1.3.5
この時点で「XXの実験環境欲しいな」とか思ったら A list of base boxes for Vagrant - Vagrantbox.es この辺から適当に欲しいVM選んでコマンドを叩く。
Debian 欲しいなとか思ったら
user@clover:~/workspace$ mkdir debian user@clover:~/workspace$ cd debian/ user@clover:~/workspace/debian$ vagrant init "Debian" "https://dl.dropboxusercontent.com/u/197673519/debian-7.2.0.box" 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.
これで vagrant の設定終了~
sudo vagrant up
と叩くと VirtualBox 上で Debian が作成される。設定する場合も
vagrant ssh
で ssh でログインできる。
他に halt
で停止、destroy
でVM破棄。
vagrant ssh-config --host debian >> ~/.ssh/config
としておけば、ssh debian
でも ssh できるようになる。