è¦ä»¶
- å ä¸ä¸æ¬ã§ãã°ããçãã¦ãããã¨ã決ããé§ãåºãï¼å¹´é½¢çã«ã¯èµ°ãçµããã«è¿ããã©ï¼ã¨ã³ã¸ãã¢ããã¤ã§ãæçåºæ¥ãç°å¢ãæ§ç¯ãã
- åããã©ãè¨ãåãã ã£ããã©ãè¦ã¯ chef-solo 㨠vagrant ãç¨æãã¦ãã¤ã§ã chef ã®ã¬ã·ããæ¸ãã¦è©¦ããç°å¢ãä½ã£ã¦ã¿ãã
- tmux ã使ã£ã¦è¤æ°ã¦ã£ã³ãã¦ã§ vagrant ã®è¨å®ã¨èµ·åãã¬ã·ãã®ä¿®æ£ãåºæ¥ããããªç°å¢ãåããã¦æ´ãã
以åã«...
- LXC で同じことをやったã®ã§ããã£ã± vagrant ããã£ã¦ãããã¨ã«ãã
- ååããç´°ããæé ãæ®ãã¦ãããã¨ã«ãã
æé
vagant ã使ããç°å¢ãæºåãã
VirtualBox ã®ã¤ã³ã¹ãã¼ã«
- é§ãåºãã®æ¿åã¯ç´ ç´ã« Ubuntu ã½ããã¦ã§ã¢ã»ã³ã¿ã¼ããã¤ã³ã¹ãã¼ã«ãã...
vagrant ã®ã¤ã³ã¹ãã¼ã«
- é§ãåºãã®æ¿å㯠VirtualBox åæ§ã« Ubuntuã½ããã¦ã§ã¢ã»ã³ã¿ã¼ããã¤ã³ã¹ãã¼ã«...
vagrant ã使ã£ã¦ã¿ã
é©å½ãªä½æ¥ãã©ã«ãããããã
mkdir ~/vagrant
vagrant box ãã
cd ~/vagrant vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
vagrant init ãã
vagrant init
ã¨ãã㨠Vagrantfile ã¨å¼ã°ããã²ãªå½¢ãã¡ã¤ã«ãä½æãããã®ã§ä»¥ä¸ã®ç¹ãä¿®æ£
Vagrant::Config.run do |config| #config.vm.box = "base" # ã³ã¡ã³ãã¢ã¦ã config.vm.box = "lucid32" # 追è¨
ããå°ãçªã£è¾¼ã㧠vagrant ã使ã£ã¦ã¿ã
- OS ã¯ä¾ã®ãã¨ã Debian
- box ã¯こちら
- ãããã¯ã¼ã¯ã®è¨å®ã« hostonly ãããã¯ã¼ã¯ã追å
- ããã¦ãchef-solo ã使ã£ã¦ provision ãã¦ã¿ã
- ä½æãã box ã®ç¢ºèªã¨åé¤ããã£ã¦ã¿ã
Debian ãä»®æ³ãã·ã³ã§èµ·åãã
ã¾ã㯠vagrant box add
vagrant box add debian http://ergonlogic.com/files/boxes/debian-current.box
次㯠vagrant init
vagrant init
Vagrantfile ãä½æããã¦ããã®ã§ãä¸è¨ã®ããã«è¨è¼ãã
Vagrant::Config.run do |config| config.vm.box = "debian" # VirtualBox ã®ã¦ã£ã³ãã¦ã表示ãããããã«ãªã config.vm.boot_mode = :gui # hostonly ãããã¯ã¼ã¯ã®è¨å® config.vm.network :hostonly, "192.168.56.2" ,:netmask => "255.255.255.0" # chef-solo ã使ã£ã¦ãµã¼ãã¼ã®è¨å®ãè¡ã config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.add_recipe "itamae" end end
VirtualBox ã®å ±æãã©ã«ãå 㧠chef-solo ã® cookbook ãä½æããï¼å ±æãã©ã«ã㯠Vagrantfile ãåå¨ãããã£ã¬ã¯ããªã«ãªãï¼
cd ~/vagrant mkdir cookbooks cd cookbooks knife cookbook create itamae -o ./
itamae cookbook ã§ä»¥ä¸ã®ãããªã¬ã·ããæ¸ã
- ä»®æ³ãã·ã³ã«ã¦ resolv.conf ã®è¨å®
- aptitude update
- 試ãã« nginx ãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã
以ä¸ãã¬ã·ãã
~/vagrant/cookbooks/itamae/recipes/default.rb
# resolv.conf ã®è¨å® template "/etc/resolv.conf" do source "resolv.conf.erb" owner "root" group "root" mode "0644" end # aptitude update ã execute ããï¼éæ¨å¥¨ï¼ï¼ execute "aptitude" do command "aptitude update" end # ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã« %w{nginx}.each do |package_name| package package_name do action :install end end
tempalete ãã¡ã¤ã«ãç¨æããï¼åçã«å¤ããè¨å®ãã¡ã¤ã«ãè¨å®ããï¼
~/vagrant/cookbooks/itamae/templates/default/resolv.conf.erb
<% node["nameservers"].each do |ns| %> nameserver <%= ns %> <% end %>
attributes ãã¡ã¤ã«ãç¨æããï¼template ã®å¤ãè¨å®ããï¼
~/vagrant/cookbooks/itamae/attributes/default.rb
default["nameservers"] = ["8.8.8.8","8.8.4.4"]
æºåãåºæ¥ãã®ã§ vagrant up ãã
vagrant up
vagrant up ã§ä»®æ³ãã·ã³ãèµ·åãããã®å¾ãchef-solo ãå®è¡ããã
ä½ææ¸ã¿ã® box ã確èªãã¦ãã¤ãã§ã«åé¤ããã£ã¦ã¿ã
ã¾ã㯠box ã®ç¢ºèª
vagrant box list
ãããªæãã§è¡¨ç¤ºããã
centos debian debian2 lucid32
è²ã
ã¨ä½ãã¾ãã
ç¶ãã¦ãä¸è¦ãª box ã®åé¤
vagrant box remove ${box_name}
chef-solo ã®ã¬ã·ããä¿®æ£ããå ´åã«ã¯ vagrant provision ãå®è¡ãã
ä»®æ³ãã·ã³ã®è¨å®ã chef-solo ã§ä¿®æ£ãããå ´åã«ã¯ã¬ã·ããé©å®ä¿®æ£ããå¾ã« vagrant provision ãå®è¡ãã
cd ~/vagrant vagrant provision
ã¨ãããã¨ã§...
hostonly ãããã¯ã¼ã¯ãä¸ãããªãçã®è²ã
ã¨ãªåé¡ãããè¦å´ãã¾ããããã¨ããããã以ä¸ã®ãããªã¬ã·ããæ¸ãç°å¢ãæ´ãã¾ãã...
ã¡ãªã¿ã« tmux ã§ã¬ã·ããæ¸ãã¦ã£ã³ãã¦ã¨ vagrant ã³ãã³ããå©ãã¦ã£ã³ãã¦ãããã¦ä»®æ³ãã·ã³ã¦ã£ã³ãã¦ã§åºåã£ã¦ã¿ã¾ãã...
ã¾ã¨ã
- vagrant ã¯ã¨ã£ã¦ãç°¡åã«ä»®æ³ãã·ã³ãä½ã£ã¦ãå£ãã¦åºæ¥ãç°å¢ãæã«å ¥ãã®ã¯å¬ãã
- Vagrant ãã¡ã¤ã«ã§è²ã ã¨ä»®æ³ãã·ã³ãè¨å®åºæ¥ãã¨ããç¹ã§ã¯ã¾ãã«ããã°ã©ããã«ã¤ã³ãã©ï¼
- ããã« chef ã puppet ãçµã¿åããããã¨ã§ç°¡åã«ãµã¼ãã¼ã®è¨å®ã¾ã§åºæ¥ã¦ãã¾ãã®ã«ãè±å¸½ï¼
- ãã ãUbuntu 12.10 ç°å¢ã§ã¯ hostonly ãããã¯ã¼ã¯ãä¸ãããªãåé¡ã«æ©ãã ï¼åèµ·åã§è§£æ±º...ï¼
- å®ç¨çãªä½¿ãæ¹ã¨ãã¦ã¯ã以ä¸ã®ãããªãã¿ã¼ã³ãèããããã...
- ãµã¼ãã¼ã®æ¤è¨¼
- éçºè ã®æ¹ã«ã¯è¤æ°ãã¿ã¼ã³ã® box ãã¡ã¤ã«ãç¨æãã¦ãã㦠vagrant box add ã ããã£ã¦ããã£ã¦ãéçºç°å¢æ§ç¯ã®æéãç縮ãã¦ããã