Skip to content

Instantly share code, notes, and snippets.

@zanshin
Last active August 29, 2015 14:10
Show Gist options
  • Save zanshin/236ecd36e1dfe22a6854 to your computer and use it in GitHub Desktop.
Save zanshin/236ecd36e1dfe22a6854 to your computer and use it in GitHub Desktop.
firewall_rules.rb
# determine if we are an alpha or production node
if node.chef_environment == "ome-alpha"
local_environment = "alpha"
else
local_environment = "prod"
end
# get the list of nodes...
sources = search(:node, "tags:#{node['memcached']['memcached_instance']} AND tags:#{local_environment}")
sources.each do |source|
firewall_rule "allow ips" do
source "#{source['ipaddress']}"
port node['memcached']['port']
protocol :tcp
action :allow
notifies :enable, 'firewall[ufw]'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment