Monthly Archives: May 2012

Getting a little crazy with FileEdit

In case there is any doubt, you can go nuts with Chef::Util::FileEdit. If one is using search_file_replace, internally it is simply: new_contents << ((method == 1) ? replace : line.gsub!(exp, replace)) Meaning if need be, I can do something silly: ruby_block ‘fix remi.repo’ do action :nothing block do f = Chef::Util::FileEdit.new(’/etc/yum.repos.d/remi.repo’) f.search_file_replace(/\$releasever/, ‘%i’ % major) [...]