<commit_before>#
# Cookbook Name:: apitrary_firewall
# Recipe:: ssh
#
# Copyright 2012, apitrary
#
# All rights reserved - Do Not Redistribute
#

include_recipe "simple_iptables"

# Get all loadbalancers
loadbalancer_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:loadbalancer")

# Allow connections from loadbalancer
loadbalancer_nodes.each do |lb_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{lb_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end

# Get all app server nodes IPs
app_server_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:appserver")

# Allow connections from app server nodes
app_server_nodes.each do |app_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{app_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end

# Get all loadbalancers
railsweb_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:railsweb")

# Allow connections from loadbalancer
railsweb_nodes.each do |railsweb_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{railsweb_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end


# Allow RabbitMQ management console from public
simple_iptables_rule "system" do
  rule "-p tcp --dport 55672"
  jump "ACCEPT"
end<commit_msg>changing rabbitmq mgmt port from 55672 to 15672<commit_after>#
# Cookbook Name:: apitrary_firewall
# Recipe:: ssh
#
# Copyright 2012, apitrary
#
# All rights reserved - Do Not Redistribute
#

include_recipe "simple_iptables"

# Get all loadbalancers
loadbalancer_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:loadbalancer")

# Allow connections from loadbalancer
loadbalancer_nodes.each do |lb_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{lb_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end

# Get all app server nodes IPs
app_server_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:appserver")

# Allow connections from app server nodes
app_server_nodes.each do |app_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{app_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end

# Get all loadbalancers
railsweb_nodes = search(:node, "chef_environment:#{node.chef_environment} AND role:railsweb")

# Allow connections from loadbalancer
railsweb_nodes.each do |railsweb_node|
  simple_iptables_rule "system" do
    rule "-p tcp -s #{railsweb_node['ipaddress']} --dport 5672"
    jump "ACCEPT"
  end
end


# Allow RabbitMQ management console from public
simple_iptables_rule "system" do
  rule "-p tcp --dport 15672"
  jump "ACCEPT"
end
{'fraction_non_alphanumeric': 0.10166919575113809, 'fraction_numerical': 0.019726858877086494, 'mean_word_length': 5.048165137614679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5555594', 'n_tokens_mistral': 943, 'n_tokens_neox': 881, 'n_words': 258}