-
-
Save scottedsa/1333592 to your computer and use it in GitHub Desktop.
Stick this in a library file...
This file contains 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
class Chef | |
class Provider | |
class File | |
class Copy < Chef::Provider::File | |
def compare_content | |
checksum(@current_resource.path) == checksum(@new_resource.content) | |
end | |
def set_content | |
unless compare_content | |
backup @new_resource.path if ::File.exists?(@new_resource.path) | |
::FileUtils.cp_r(@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 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