1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

why-run 時に ruby_block リソースを実行する whyrun_safe_ruby_block

Last updated at Posted at 2015-02-07

実は whyrun_safe_ruby_block というドキュメントには書かれていないリソースがあって、そちらを使うと why-run の時も走る。

recipes/test.rb
whyrun_safe_ruby_block "foobar" do
  block do
    puts 'foobar'
  end
end

さらに if Chef::Config[:why_run] とかすれば why-run の時だけ走らせるなんてことも実現できる。

recipes/test.rb
if Chef::Config[:why_run]
  whyrun_safe_ruby_block "foobar" do
    block do
      puts 'foobar'
    end
  end
end
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?