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.action :nothing
f.content from_encrypted_databag
f.run_action(:create)
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