LoginSignup
10
7

More than 5 years have passed since last update.

[Chef]recipe中でchef-clientの実行を中止する

Last updated at Posted at 2013-01-10

raiseが使えそうです。

sample.rb
Chef::Log::info( node.chef_environment + " is environment." )
if node.chef_environment != "production"
  raise "Environment does not match!"
end
結果
[root@chef ~]# chef-client

[2013-01-10T14:44:11+09:00] INFO: *** Chef 10.14.4 ***
...
[2013-01-10T14:47:10+09:00] INFO: _default is environment.
...
RuntimeError
------------
Environment does not match!
...
Cookbook Trace:
...
 14>>   raise "Environment does not match!"

※単にEnvironment別の処理をするだけならEnvironmentの機能を使ってもできます。

10
7
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
10
7