chef備忘録

  • 新しくレシピ作る
knife cookbook create foo -o cookbooks
  • 別ノードを準備する
knife solo prepare user@host
  • 別ノードのレシピを実行する
knfe solo cook host
  • knife-soloをソースからインストールしたらエラーがでた。

どうやら前のバージョンのknife-soloが呼ばれている感じ。
以下のようにアンインストールすれば直った。

gem uninstall knife-solo --version '= 0.2.0'
% knife solo init mychef-repo                                                                                                                                      [~/recipe]
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require': cannot load such file -- knife-solo/kitchen_command (LoadError)
	from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
	from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/knife-solo-0.2.0/lib/chef/knife/solo_bootstrap.rb:5:in `<top (required)>'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb:37:in `load'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb:37:in `block in load_commands'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb:37:in `each'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb:37:in `load_commands'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife.rb:119:in `load_commands'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife.rb:167:in `run'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/application/knife.rb:123:in `run'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/bin/knife:25:in `<top (required)>'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/knife:19:in `load'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/knife:19:in `<main>'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
	from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
% vi /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb                                                                          [~/recipe]
% vi /usr/local/rvm/gems/ruby-1.9.3-p194/gems/chef-11.4.0/lib/chef/knife/core/subcommand_loader.rb                                                                          [~/recipe]
% gem uninstall knife-solo --version '= 0.2.0'                                                                                                                              [~/recipe]
Successfully uninstalled knife-solo-0.2.0
% knife solo init mychef-repo                                                                                                                                               [~/recipe]
Creating kitchen...
Creating knife.rb in kitchen...
Creating cupboards...
  • nginxをインストールする

CentOSは yumのEPELというアドオンを有効にしないと nginx が取得できないので、
yumのEPELをyumクックブックで有効にする。

knife cookbook site vendor yum

あとはこの辺を参考に
https://gist.github.com/tango238/5426579