Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

automatic iptables and runit courtesy of cliff

  • Loading branch information...
commit af2cfe8e07fdd4f297e134f2f172f9828e346046 1 parent 0d38579
@b authored
View
1  cassandra/attributes/cassandra.rb
@@ -11,6 +11,7 @@
set_unless[:cassandra][:seeds] = ["127.0.0.1"]
set_unless[:cassandra][:rpc_timeout] = 5000
set_unless[:cassandra][:commit_log_rotation_threshold] = 128
+set_unless[:cassandra][:jmx_port] = 8080
set_unless[:cassandra][:listen_addr] = "localhost"
set_unless[:cassandra][:storage_port] = 7000
set_unless[:cassandra][:thrift_addr] = "localhost"
View
3  cassandra/metadata.rb
@@ -5,10 +5,13 @@
version "0.1"
recipe "cassandra::autoconf", "Automatically configure nodes from chef-server information."
recipe "cassandra::ec2snitch", "Automatically configure properties snitch for clusters on EC2."
+recipe "cassandra::iptables", "Automatically configure iptables rules for cassandra."
depends "java"
+depends "runit"
%w{ubuntu debian}.each do |os|
supports os
+ depends "iptables"
end
attribute "cassandra",
View
7 cassandra/recipes/autoconf.rb
@@ -49,15 +49,18 @@
clusters[node[:cassandra][:cluster_name]].each_pair do |k, v|
node[:cassandra][k] = v
end
+node.save
local_addr = "" ; seeds = []
if node[:rackspace]
local_addr = node[:rackspace][:private_ip]
- seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n['rackspace']['private_ip']}
+ seeds = (search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map do |n|
+ n["rackspace"]["private_ip"] if n["rackspace"]
+ end).compact
seeds = ["127.0.0.1"] unless seeds.length > 0
else
local_addr = node[:ipaddress]
- seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n['ipaddress']}
+ seeds = search(:node, "cassandra_cluster_name:#{node[:cassandra][:cluster_name]} AND cassandra_seed:true").map {|n| n["ipaddress"]}
seeds = ["127.0.0.1"] unless seeds.length > 0
end
View
22 cassandra/recipes/default.rb
@@ -19,16 +19,38 @@
#
include_recipe "java"
+include_recipe "runit"
package "cassandra" do
action :install
end
+runit_service "cassandra"
+
service "cassandra" do
supports :status => true, :restart => true, :reload => true
action [ :enable, :start ]
end
+user "cassandra" do
+ gid "nogroup"
+ shell "/bin/false"
+end
+
+directory "/var/lib/cassandra" do
+ owner "cassandra"
+ group "root"
+ mode "0755"
+ action :create
+end
+
+directory "/var/log/cassandra" do
+ owner "cassandra"
+ group "root"
+ mode "0755"
+ action :create
+end
+
directory "/etc/cassandra" do
owner "root"
group "root"
View
25 cassandra/recipes/iptables.rb
@@ -0,0 +1,25 @@
+#
+# Author:: Benjamin Black (<b@b3k.us>)
+# Cookbook Name:: cassandra
+# Recipe:: iptables
+#
+# Copyright 2010, Benjamin Black
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "iptables"
+
+iptables_rule "10cassandra" do
+ source "iptables.erb"
+end
View
4 cassandra/templates/default/iptables.erb
@@ -0,0 +1,4 @@
+# Generated by Chef for <%= @node[:fqdn] %>
+-A INPUT -p TCP --dst <%= @node[:cassandra][:listen_addr] %> --dport <%= @node[:cassandra][:storage_port] %> -j ACCEPT
+-A INPUT -p TCP --dst <%= @node[:cassandra][:listen_addr] %> --dport <%= @node[:cassandra][:jmx_port] %> -j ACCEPT
+-A INPUT -p TCP --dst <%= @node[:cassandra][:thrift_addr] %> --dport <%= @node[:cassandra][:thrift_port] %> -j ACCEPT
View
2  cassandra/templates/default/sv-cassandra-log-run.erb
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
View
3  cassandra/templates/default/sv-cassandra-run.erb
@@ -0,0 +1,3 @@
+#!/bin/sh
+exec 2>&1
+exec chpst -u cassandra /usr/sbin/cassandra -f

0 comments on commit af2cfe8

Please sign in to comment.
Something went wrong with that request. Please try again.