Skip to content

Instantly share code, notes, and snippets.

@greinacker greinacker/1.rb
Created Oct 18, 2012

Embed
What would you like to do?
Per-host Capistrano tasks
role :web, "192.168.1.132", :internal => "10.0.0.1"
role :app, "192.168.1.133", :internal => "10.0.0.2"
role :db, "192.168.1.132", :primary => true
role :db, "192.168.1.134", :no_release => true, :internal => "10.0.0.3"
all_internal_ips = Array.new
servers = find_servers_for_task(current_task)
servers.each do |s|
ip = s.options[:internal]
if !ip.nil? && ip.length > 0
all_internal_ips.push(ip) unless all_internal_ips.include?(ip)
end
end
servers.each do |s|
all_internal_ips.each do |addr|
line = "-A INPUT -s #{addr} -i eth0 -d #{s.options[:internal]} -j ACCEPT"
run "#{try_sudo} bash -c \" echo '#{line}' >> /etc/iptables.up.rules\"", :hosts => s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.