-
-
Save hh/4384614 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
class Chef | |
class Provider | |
class File | |
class Copy < Chef::Provider::File | |
def content_differs | |
checksum(@current_resource.path) != checksum(@new_resource.content) | |
end | |
def set_content | |
if content_differs | |
backup @new_resource.path if ::File.exists?(@new_resource.path) | |
::FileUtils.cp(@new_resource.content, @new_resource.path) | |
Chef::Log.info("#{@new_resource.content} copied to #{@new_resource.path}") | |
@new_resource.updated_by_last_action(true) | |
end | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file "/tmp/foo" do | |
content "/tmp/bar" | |
provider Chef::Provider::File::Copy | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment