Method: Chef::Provider::File#set_content
- Defined in:
- lib/chef/provider/file.rb
#set_content ⇒ Object
Set the content of the file, assuming it is not set correctly already.
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/chef/provider/file.rb', line 185 def set_content unless compare_content description = [] description << "update content in file #{@new_resource.path} from #{short_cksum(@current_resource.checksum)} to #{short_cksum(new_resource_content_checksum)}" description << diff_current_from_content(@new_resource.content) converge_by(description) do backup @new_resource.path if ::File.exists?(@new_resource.path) ::File.open(@new_resource.path, "w") {|f| f.write @new_resource.content } Chef::Log.info("#{@new_resource} contents updated") end end end |