Navigation Menu

Skip to content

実験環境(仮想環境)の構築

YUKI "Piro" Hiroshi edited this page Apr 8, 2014 · 15 revisions

vagrantで「ubuntu13.10」という名前の実験環境を用意する。

仮想マシンのホストとなる環境のセットアップ

% sudo gem1.9.1 install chef knife-solo

実験環境としての仮想マシンのセットアップ(vagrant使用、Ubuntu 13.10)

% vagrant box add ubuntu13.10 http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box
% mkdir testserver
% cd testserver
% vagrant init ubuntu13.10

設定を書き換えて、固定IPで接続できるようにする。

% ip=192.168.1.54
% net=wlan0
% mv Vagrantfile Vagrantfile.bak
% cat Vagrantfile.bak | \
  sed -r -e "s/(^ *)# *(config.vm.network *:bridged)/\1\2, :ip => \"${ip}\", :bridge => \"${net}\"/" \
  > Vagrantfile
% vagrant ssh-config --host ubuntu13.10 | \
  sed -r -e "s/2222/22/" \ 
         -e "s/127.0.0.1/${ip}/" \
  >> ~/.ssh/config

設定ができたか確認する。

% vagrant up
% vagrant ssh
% exit
% ssh vagrant@${ip} -p 22 -i ~/.vagrant.d/insecure_private_key
% exit
% ssh ubuntu13.10
% exit