Skip to content

Instantly share code, notes, and snippets.

@spheromak
Created November 28, 2009 04:03
Show Gist options
  • Save spheromak/244382 to your computer and use it in GitHub Desktop.
Save spheromak/244382 to your computer and use it in GitHub Desktop.
# multi instance stuff
if @node[:postfix_multi]
# loop over all multi instances and asemble templates.
postconf = Hash.new
@node[:postfix_multi].each do |instance, settings|
# convert postfix config into hash to merge into
# mult-instance config
h = Hash.new
@node[:postfix].each do |k,v|
h[k] = v
end
postconf = h.merge(settings)
h.clear
template "/etc/#{instance}/main.cf" do
source "main.cf.fm.erb"
notifies :reload, resources(:service => "postfix")
# so much pain here.. need to pass in an array. may as well sort it.
# could also use .to_a to flatten this.
variables(:postconf => postconf.sort)
end
postconf.clear
end
end
<% @postconf.each do |k, v| -%>
<%= k %>=<%= v %>
<% end -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment