Skip to content

Instantly share code, notes, and snippets.

@thommay
Forked from adamhjk/rsync_conf.rb
Created February 22, 2010 10:31
Show Gist options
  • Save thommay/310990 to your computer and use it in GitHub Desktop.
Save thommay/310990 to your computer and use it in GitHub Desktop.
# rsync/definition/rsync_target.rb
define :rsync_target, :path => nil, :comment => nil, :action => :set do
t = begin
resources(:template => "/etc/rsyncd.conf")
rescue
template "/etc/rsyncd.conf" do
owner "root"
group "root"
source "rsyncd.conf.erb"
cookbook "rsyncd"
variables { :targets => {} }
end
end
target_opts = params.clone
target_opts.delete(:name)
case params[:action]
when :set
t.variables[:targets].merge({ params[:name] => target_opts})
when :unset
t.variables[:targets].delete(params[:name])
end
end
# rsync/templates/rsyncd.conf.erb
<%- @targets.sort.each do |target| %>
[<%= target[0] %>]
<%- target[1].each do |attr, value| %>
<%= attr %> = <%= value %>
<%- end %>
<%- end %>
# some recipe
rsync_target "snoopy" do
path "/tmp/snoopy"
comment "I like to snoop"
uid "francis"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment