Chefcheatsheet
贡献者:BAI
安装
BASHsudo apt-get install curl
BASH$ curl -L https://omnitruck.chef.io/install.sh | sudo bashThank you for installing Chef!
BASH$ chef-solo -v...Chef: 14.5.33
启动 Cookbook
BASHwget http://github.com/chef-cookbooks/chef-repo/tarball/master -O - | tar xzf - --strip-components=1
Knife
BASHknife supermarket download mysql
调用 chef-solo
BASHchef-solo -c solo.rb -j web.json
示例
简单的编译源码
RUBYexecute "tar --no-same-owner -zxf hi.tar.gz" do cwd "/usr/local/src" creates "/usr/local/src/node-v#{version}"end
RUBYbash "compile" do cwd "/usr/local/src/node-v#{version}" code %[ PATH=/usr/local/bin:$PATH ./configure make ] creates "/usr/local/src/node-v#{version}/node"end
远程文件
RUBYremote_file "/usr/local/src/hi.tar.gz" do source "http://..." checksum "ab83be..." mode 0644 action :create_if_missingend
ruby_block
RUBYruby_block "name" do block { File.read ... } not_if { File.exists?(...) }end
执行
RUBYexecute "name" do cwd "..." environment({ "PATH" => "..." }) command "make install" creates "..."end
条件判断
RUBYcreates "/usr/local/src/node-v#{version}/node" not_if { File.exists?('...') }
其他资料
- Learn Chef Rally (learn.chef.io)
- install_from_source.rb recipe (github.com)