Created
February 20, 2010 02:08
-
-
Save adamhjk/309444 to your computer and use it in GitHub Desktop.
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
# 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