- From: Joe Nuspl <
>
- To:
- Subject: [chef] Disabling logger/formater on a per-resource basis
- Date: Wed, 12 Feb 2014 16:26:16 -0800
Ohai!
I love seeing the diffs during chef-client/chef-solo runs. It is such a huge aid in debugging.
That being said, there are certain resources, i.e. key files, where I don’t want this enabled.
I’m currently dealing with this like:
saved = Chef::Config[:diff_filesize_threshold] Chef::Config[:diff_filesize_threshold] = 0 f = Chef::File::Resource.new(path, run_context) f.action :nothing f.content from_encrypted_databag f.run_action(:create) Chef::Config[:diff_filesize_threshold] = saved
It is really ugly, but it gets the job done. Taking inspiration from nod from chef-sugar, I could do something like:
def quietly(&block)
saved = Chef::Config[:diff_filesize_threshold] Chef::Config[:diff_filesize_threshold] = 0 begin instance_eval(&block) rescue Exception => ex Chef::Config[:diff_filesize_threshold] = saved raise ex end Chef::Config[:diff_filesize_threshold] = saved
end
And then do:
quietly do f = Chef::File::Resource.new(filename, run_context) f.content from_encrypted_databag end
Is there a better way of doing this? Maybe:
file filename do action :create content from_encrypted_databag with {:diff_filesize_threshold => 0 } end
Thanks.
Joe |
- [chef] Disabling logger/formater on a per-resource basis, Joe Nuspl, 02/12/2014
Archive powered by MHonArc 2.6.16.