Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Chef | resources | rubyで任意のスクリプトを実行

概要

rubyで任意のスクリプトを実行

詳細

rubyで任意のスクリプトを実行します。
※冪統性の保証を自分で行う必要がある。

ruby "some name" do
  # options
end

詳細については公式サイトリンクを参照。
http://docs.opscode.com/chef/resources.html#ruby

サンプル

コード

ruby_resource_create1〜3ディレクトリを作成します

ruby "create dir" do
  user "vagrant"
  cwd "/home/vagrant/work"
  code <<-EOS
Dir.mkdir("ruby_resource_create1")
Dir.mkdir("ruby_resource_create2")
  EOS
end
実行結果確認
$ cd work
$ ls
ruby_resource_create1  ruby_resource_create2