読者です 読者をやめる 読者になる 読者になる

chefのログ出力を制限する方法 / 劇的ビフォーアフター ver.0.10.6+ (verbose_logging)

chef

chefのログが出すぎだなー、実際これ影響あるのかないのか
出力結果見るのにターミナルでスクロールバックしないといけないし
これだけの出力されたログの中で、影響があるのかないのか、ひとつひとつ
grep警部してたら取りこぼし多そうだなー

やだなやだなー、こわいなこわいなー

と思ってたんですが


Chef 0.10.6 Released

「optionally disable the verbose logging」という表記があるじゃないですか!!


リンク先を覗くと

The "processing" INFO message for every resource on a normal run looks nice but is probably too verbose. 
The messages are great if you're running chef-client in your terminal and want to know whats happening, 
but will fill up logfiles with unnecessary cruft. Also, using knife ssh will cause an explosion of ASCII proportions.

おお、そうなんだよ!!Processingはバーボスなんだよ!!
本当にほしいログってのはサーバに影響を及ぼしだログだけで
他のログはそんなに必要じゃないんだよおおおお!!!

わかるぜブラザー!!よっしゃ!
取り敢えずはコミット内容を見てみよう!!!

https://github.com/mdkent/chef/commit/c96ca45f1bc0cdb45925890f161847d680ae2fd7

( ◔౪◔) ?

ちょっと意味がわからない。。って思ってたらなんと

Chef Configuration Settings

ドキュメントに載ってました。

verbose_logging set to true or nil

verbose_logging set to false
In Chef 0.10.6+, setting verbose_logging to false

これか!! verbose_logging set to falseッッ!!


ど、どこに書いたらええんや!!!
どこなんやああああああああああああああああああああ!!!

と、血眼になって探したのですが
上記マニュアルの上の方に書いてありますね。

 chef-solo なら /etc/chef/solo.rb  
 chef-client なら /etc/chef/client.rb

ということで、うちは chef-solo を利用しているので
早速 /etc/chef/solo.rb に 「verbose_logging false」を記入して実行してみましょう

before



after

beforeの内容 (一部消しております)

[root@eto-server chef]#
[root@eto-server chef]# chef-solo -c config/solo.rb -j config/self.json
[2012-10-31T18:16:58+09:00] INFO: *** Chef 10.16.0 ***
[2012-10-31T18:16:58+09:00] INFO: Setting the run_list to ["zabbix", "nginx"] from JSON
[2012-10-31T18:16:58+09:00] INFO: Run List is [recipe[zabbix], recipe[nginx]]
[2012-10-31T18:16:58+09:00] INFO: Run List expands to [ne, ushi, tora]
[2012-10-31T18:16:58+09:00] INFO: Starting Chef Run for eto-server
[2012-10-31T18:16:58+09:00] INFO: Running start handlers
[2012-10-31T18:16:58+09:00] INFO: Start handlers complete.
[2012-10-31T18:16:59+09:00] INFO: Processing tem
[2012-10-31T18:16:59+09:00] INFO: Processing tem
[2012-10-31T18:16:59+09:00] INFO: Processing tem
[2012-10-31T18:16:59+09:00] INFO: Processing fil
[2012-10-31T18:16:59+09:00] INFO: Processing fil
[2012-10-31T18:16:59+09:00] INFO: Processing pac
[2012-10-31T18:16:59+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing gro
[2012-10-31T18:17:04+09:00] INFO: Processing gro
[2012-10-31T18:17:04+09:00] INFO: Processing gro
[2012-10-31T18:17:04+09:00] INFO: Processing gro
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing dir
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing dir
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing dir
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing dir
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing use
[2012-10-31T18:17:04+09:00] INFO: Processing dir
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing gro
[2012-10-31T18:17:04+09:00] INFO: Processing pac
[2012-10-31T18:17:04+09:00] INFO: Processing tem
[2012-10-31T18:17:04+09:00] INFO: Processing tem
[2012-10-31T18:17:04+09:00] INFO: Processing tem
[2012-10-31T18:17:04+09:00] INFO: Processing fil
[2012-10-31T18:17:04+09:00] INFO: Processing ser
[2012-10-31T18:17:04+09:00] INFO: Processing ser
[2012-10-31T18:17:04+09:00] INFO: Processing ser
[2012-10-31T18:17:05+09:00] INFO: Processing ser
[2012-10-31T18:17:05+09:00] INFO: Processing ser
[2012-10-31T18:17:05+09:00] INFO: service[nginx]
[2012-10-31T18:17:05+09:00] INFO: Processing ser
[2012-10-31T18:17:06+09:00] INFO: service[nginx]
[2012-10-31T18:17:06+09:00] INFO: Processing ser
[2012-10-31T18:17:06+09:00] INFO: Processing ser
[2012-10-31T18:17:06+09:00] INFO: Processing ser
[2012-10-31T18:17:06+09:00] INFO: Processing ser
[2012-10-31T18:17:07+09:00] INFO: Processing ser
[2012-10-31T18:17:07+09:00] INFO: Processing ser
[2012-10-31T18:17:07+09:00] INFO: Processing ser
[2012-10-31T18:17:07+09:00] INFO: Processing ser
[2012-10-31T18:17:07+09:00] INFO: Processing ser
[2012-10-31T18:17:08+09:00] INFO: service[nginx]
[2012-10-31T18:17:08+09:00] INFO: Processing ser
[2012-10-31T18:17:08+09:00] INFO: service[nginx]
[2012-10-31T18:17:08+09:00] INFO: Processing exe
[2012-10-31T18:17:08+09:00] INFO: Processing tem
[2012-10-31T18:17:08+09:00] INFO: Processing coo
[2012-10-31T18:17:08+09:00] INFO: Processing lin
[2012-10-31T18:17:08+09:00] INFO: Processing tem
[2012-10-31T18:17:08+09:00] INFO: Processing pac
[2012-10-31T18:17:08+09:00] INFO: Processing tem
[2012-10-31T18:17:08+09:00] INFO: Processing ser
[2012-10-31T18:17:08+09:00] INFO: Processing ser
[2012-10-31T18:17:09+09:00] INFO: Processing pac
[2012-10-31T18:17:09+09:00] INFO: Processing ser
[2012-10-31T18:17:09+09:00] INFO: Processing ser
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing dir
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing coo
[2012-10-31T18:17:09+09:00] INFO: Processing coo
[2012-10-31T18:17:09+09:00] INFO: Processing coo
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing pac
[2012-10-31T18:17:09+09:00] INFO: Processing bas
[2012-10-31T18:17:09+09:00] INFO: Processing fil
[2012-10-31T18:17:09+09:00] INFO: Processing pac
[2012-10-31T18:17:09+09:00] INFO: Processing pac
[2012-10-31T18:17:09+09:00] INFO: Processing tem
[2012-10-31T18:17:09+09:00] INFO: Processing ser
[2012-10-31T18:17:09+09:00] INFO: Processing ser
[2012-10-31T18:17:09+09:00] INFO: Chef Run complete in 10.76644 seconds
[2012-10-31T18:17:09+09:00] INFO: Running report handlers
[2012-10-31T18:17:09+09:00] INFO: Report handlers complete
[root@eto-server chef]#

afterの内容

[root@musashi chef]# chef-solo -c config/solo.rb -j config/self.json
[2012-10-31T18:13:56+09:00] INFO: *** Chef 10.16.0 ***
[2012-10-31T18:13:57+09:00] INFO: Setting the run_list to ["zabiix", "nginx"] from JSON
[2012-10-31T18:13:57+09:00] INFO: Run List is [recipe[zabbix], recipe[nginx]]
[2012-10-31T18:13:57+09:00] INFO: Run List expands to [zabbix, nginx]
[2012-10-31T18:13:57+09:00] INFO: Starting Chef Run for eto-server
[2012-10-31T18:13:57+09:00] INFO: Running start handlers
[2012-10-31T18:13:57+09:00] INFO: Start handlers complete.
[2012-10-31T18:14:04+09:00] INFO: service[nginx] disabled
[2012-10-31T18:14:04+09:00] INFO: service[nginx] stopped
[2012-10-31T18:14:06+09:00] INFO: service[nginx] enabled
[2012-10-31T18:14:07+09:00] INFO: service[nginx] started
[2012-10-31T18:14:08+09:00] INFO: Chef Run complete in 10.505194 seconds
[2012-10-31T18:14:08+09:00] INFO: Running report handlers
[2012-10-31T18:14:08+09:00] INFO: Report handlers complete
[root@musashi chef]#


影響があったものだけが出力されるようになる。

It's very simple!!

ということで、他のアップデート内容は確認していませんが
このログ出力制限のためだけでも chef を 0.10.6 にアップデートしても良いなと思いました。

Why-runも使えるし、0.10.6、なかなか良いですね。