vagrant + berkshelf + chefã§ç°å¢ãã¤ãã£ã¦ã¿ããé¼»è¡ãåºã
vagrantのチュートリアルをやったログã§vagrantã®ä¾¿å©ãã¨ãããã®ä½¿ãæ¹ã¯ç解ã§ããã
ãã¨ãã¨Chefã®ã¬ã·ããä½ãç°å¢ãç¨æããããã¨ããã®ã主é¡ã ã£ãã®ã§ä»åã¯Vagrantãæ´»ããã¦Chefã®ã¬ã·ããæ¸ãã¦ã¿ããã¨ããã¨ãããæè¿ããBerkshelfã¨ãããã¼ã«ããã£ã¦ãããæ´»ããã¨ã¤ã«ã¹ãã¨ã«ãªãã£ã¦ãã£ã±ãã®åã ã£ãã®ã§è©¦ãã¦ã¿ãã¡ã¢ã
å ¥éChef Solo - Infrastructure as Code
- ä½è : ä¼è¤ç´ä¹
- åºç社/ã¡ã¼ã«ã¼: ä¼è¤ç´ä¹
- çºå£²æ¥: 2013/03/11
- ã¡ãã£ã¢: Kindleç
- è³¼å ¥: 16人 ã¯ãªãã¯: 1,027å
- ãã®ååãå«ãããã° (19件) ãè¦ã
Berkshelfã¯cookbookã管çãã¦ããããã¼ã«ãbundler->gemã®ããã«berkshelf->cookbookã¨ããã¤ã¡ã¼ã¸ã
å
·ä½çã«ã©ãããã¡ãªããããããã¨ããã¨ãå¥ããã¸ã§ã¯ãã®ã¬ã·ãã交ããrun_listãçµãããã¨ãããã¨ãã¤ã¾ããchefãªãã¸ããªã¨ããã¸ã§ã¯ãã®çµåã解æ¶ã§ãããã¨ãã°ãããã¾ã§ããã¸ã§ã¯ããã¨ã«chef-repoãæ§ãã¦ããã±ã¼ã¹ãªã©ã§ãããã¡ã ã£ããè¤æ°ããã¸ã§ã¯ãã«æ¸¡ã£ã¦å
±éå©ç¨ããcookbookã®éè¤ç®¡çã解æ¶ã§ããããããããèªåã§ã¬ã·ããæ¸ããã«https://github.com/aws/opsworks-cookbooksã®ããã«å
¬éããã¦ãããã®ãçµã¿åããã¦å©ç¨ã§ãããªã©ã®ã¡ãªãããããã
ä»åã®è©¦ã¿ã¨ãã¦ãrbenvãã¤ã³ã¹ãã¼ã«ãã¦Ruby2.0ãã¤ã³ã¹ãã¼ã«ãã¦globalã«è¨å®ãããã¨ããã®ããã£ã¦ã¿ãã
berkshelfã®ã¤ã³ã¹ãã¼ã«
ã¤ã³ã¹ãã¼ã«ã¯gemã§ä¸çºã
$ gem install berkshelf
cookbookä½æ
ã¡ã¤ã³ã®cookbookãä½ãã
$ berks cookbook test
ããã¨ããã«Cookbookã»ããï¼Vagrantfile + Berksfileãçæãããããã®Cookbookãããã¸ã§ã¯ãåºæã®ã¬ã·ãã¨ãªãããã以å¤ã®Cookbookã¯å¥ã§ç®¡çããã¦ãããã®ã使ãã®ãæµåãã»ã»ã»ãªãã ã¨æãã
å¤é¨ã®cookbookãã¤ã³ã¹ãã¼ã«ãã
ã¨ãããããrbenvã®Cookbookã調éãããå¤é¨ã®Cookbookã®èª¿éã¯Berksfileã«ã¡ããã£ã¨æ¸ãã ãã§ã¤ã±ãã
Berksfile
site :opscode metadata cookbook 'rbenv', ">= 1.4.1" , git: 'git://github.com/RiotGames/rbenv-cookbook.git'
ãããªæãã«å®ç¾©ããã
ã¤ã³ã¹ãã¼ã«
$ berks install
ããã§ããã©ã«ãã ã¨~/.berkshelf/cookbooks/ã«æå®ããcookbookã¨ãã®ä¾åé¢ä¿ã®ããcookbookããã¦ã³ãã¼ããããtest cookbookå
ã®ã¬ã·ãããincludeãããã¨ãã§ããã
ã¡ã¤ã³ã®ã¬ã·ããæ¸ã
ãªãã®å¤å²ããªãã¬ã·ãããããªæãã
test/recipes/default.rb
include_recipe 'rbenv::default' include_recipe 'rbenv::ruby_build' rbenv_ruby "2.0.0-p195" do ruby_version "2.0.0-p195" global true end
Vagrantã®è¨å®
ãã£ãæ¸ããã¬ã·ããVMèµ·åæã«å¼ã³åºãããè¨å®ããã
Vagrantfile
~snip~ config.berkshelf.enabled = true ~snip~ config.vm.provision :chef_solo do |chef| chef.run_list = [ "recipe[test]" ] end
config.berkshelf.enabled = true
ã¯berks cookbook testããã¨ãã«ä½ãããVagrantfileã«åæã«è¨è¼ããã¦ããã
ãã¨ãèªåã§ä½ãããVagrantfileã¯ãããã¯ã¼ã¯è¨å®ãprivate_networkã«ãªã£ã¦ããããã®ã§ããã®è¾ºãé©å®é½åã®ããããã«ä¿®æ£ãã¦ããã
berkshelfãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«
ãã®ã¾ã¾vagrant upããã¨berkshelfãªãã¦è¨å®é ç®ãã¼ããã¨è¨ãããã®ã§vagrantã¨é£æºã§ããããvagrantã®berkshelfãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ããã
$ vagrant plugin install vagrant-berkshelf
vagrant up
ãã¨ã¯vagrant upããã ããããããã§ã«upãã¦ããå ´åã§ãå度ã¬ã·ããå®è¡ãããå ´åã¯
$ vagrant provision
ã¨ããã³ãã³ããããã
rubyã®ã¤ã³ã¹ãã¼ã«ã¯æéãããããã©ãã¨ã¯å¾
ã¤ã ãã®ã¯ãã»ã»ã»
確èª
$ vagrant ssh [vagrant@test-berkshelf ~]$ ruby -v ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
ããã¼ãã§ãã¦ãããªã«ãããã¢ãã
é¼»è¡ããããã¼ã
- ä½è : Mitchell Hashimoto
- åºç社/ã¡ã¼ã«ã¼: Oreilly & Associates Inc
- çºå£²æ¥: 2013/06/12
- ã¡ãã£ã¢: ãã¼ãã¼ããã¯
- ã¯ãªãã¯: 5å
- ãã®ååãå«ãããã° (2件) ãè¦ã