-
-
Save greinacker/3915166 to your computer and use it in GitHub Desktop.
Per-host Capistrano tasks
This file contains hidden or 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
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" |
This file contains hidden or 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
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 |
This file contains hidden or 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
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