Skip to content

Instantly share code, notes, and snippets.

@tily
Created October 21, 2012 13:43
Show Gist options
  • Save tily/3927000 to your computer and use it in GitHub Desktop.
Save tily/3927000 to your computer and use it in GitHub Desktop.
require 'digest/md5'
action :sync do
old_checksum = ::File.exists?(new_resource.name) ? ::Digest::MD5.file(new_resource.name) : nil
execute "rsync file" do
command "rsync -a -e '#{new_resource.command}' #{new_resource.source} #{new_resource.name}"
end
ruby_block "see if rsync_file[#{new_resource.name}] was updated" do
block do
new_checksum = ::Digest::MD5.file(new_resource.name)
if old_checksum && old_checksum != new_checksum
new_resource.updated_by_last_action true
end
end
end
end
actions :sync
attribute :name, :required => true, :kind_of => String, :name_attribute => true
attribute :source, :required => true, :kind_of => String
attribute :command, :required => true, :kind_of => String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment