diff --git a/mongodb/attributes/default.rb b/mongodb/attributes/default.rb index fa59bbb..86c967a 100755 --- a/mongodb/attributes/default.rb +++ b/mongodb/attributes/default.rb @@ -19,6 +19,7 @@ default[:mongodb][:dbpath] = "/var/lib/mongodb" default[:mongodb][:logpath] = "/var/log/mongodb" +default[:mongodb][:bind_ip] = nil default[:mongodb][:port] = 27017 # cluster identifier @@ -44,7 +45,7 @@ default[:mongodb][:root_group] = "wheel" default[:mongodb][:package_name] = "mongodb" -when "centos","redhat","fedora","amazon" +when "centos","redhat","fedora","amazon","scientific" default[:mongodb][:defaults_dir] = "/etc/sysconfig" default[:mongodb][:package_name] = "mongo-10gen-server" default[:mongodb][:user] = "mongod" @@ -55,5 +56,6 @@ default[:mongodb][:defaults_dir] = "/etc/default" default[:mongodb][:root_group] = "root" default[:mongodb][:package_name] = "mongodb-10gen" + default[:mongodb][:apt_repo] = "debian-sysvinit" end diff --git a/mongodb/definitions/mongodb.rb b/mongodb/definitions/mongodb.rb index f112d45..d5a538b 100755 --- a/mongodb/definitions/mongodb.rb +++ b/mongodb/definitions/mongodb.rb @@ -19,10 +19,10 @@ # limitations under the License. # -define :mongodb_instance, :mongodb_type => "mongod" , :action => [:enable, :start], :port => 27017 , \ - :logpath => "/var/log/mongodb", :dbpath => "/data", :configfile => "/etc/mongodb.conf", \ - :configserver => [], :replicaset => nil, :enable_rest => false, \ - :notifies => [] do +define :mongodb_instance, :mongodb_type => "mongod" , :action => [:enable, :start], + :bind_ip => nil, :port => 27017 , :logpath => "/var/log/mongodb", + :dbpath => "/data", :configfile => "/etc/mongodb.conf", :configserver => [], + :replicaset => nil, :enable_rest => false, :notifies => [] do include_recipe "mongodb::default" @@ -31,6 +31,7 @@ service_action = params[:action] service_notifies = params[:notifies] + bind_ip = params[:bind_ip] port = params[:port] logpath = params[:logpath] @@ -93,6 +94,7 @@ "name" => name, "config" => configfile, "configdb" => configserver, + "bind_ip" => bind_ip, "port" => port, "logpath" => logfile, "dbpath" => dbpath, @@ -139,7 +141,9 @@ service name do supports :status => true, :restart => true action service_action - notifies service_notifies + service_notifies.each do |service_notify| + notifies :run, service_notify + end if !replicaset_name.nil? notifies :create, "ruby_block[config_replicaset]" end diff --git a/mongodb/metadata.rb b/mongodb/metadata.rb index 8475652..9063585 100755 --- a/mongodb/metadata.rb +++ b/mongodb/metadata.rb @@ -1,8 +1,9 @@ +name "mongodb" maintainer "edelight GmbH" maintainer_email "markus.korn@edelight.de" license "Apache 2.0" description "Installs and configures mongodb" -version "0.11" +version "0.12" recipe "mongodb", "Installs and configures a single node mongodb instance" recipe "mongodb::10gen_repo", "Adds the 10gen repo to get the latest packages" @@ -14,7 +15,7 @@ depends "apt" depends "yum" -%w{ ubuntu debian freebsd centos redhat fedora amazon }.each do |os| +%w{ ubuntu debian freebsd centos redhat fedora amazon scientific}.each do |os| supports os end @@ -22,22 +23,22 @@ :display_name => "dbpath", :description => "Path to store the mongodb data", :default => "/var/lib/mongodb" - + attribute "mongodb/logpath", :display_name => "logpath", :description => "Path to store the logfiles of a mongodb instance", :default => "/var/log/mongodb" - + attribute "mongodb/port", :display_name => "Port", :description => "Port the mongodb instance is running on", :default => "27017" - + attribute "mongodb/client_roles", :display_name => "Client Roles", :description => "Roles of nodes who need access to the mongodb instance", :default => [] - + attribute "mongodb/cluster_name", :display_name => "Cluster Name", :description => "Name of the mongodb cluster, all nodes of a cluster must have the same name.", @@ -46,8 +47,8 @@ attribute "mongodb/shard_name", :display_name => "Shard name", :description => "Name of a mongodb shard", - :default => "default" - + :default => "default" + attribute "mongodb/sharded_collections", :display_name => "Sharded Collections", :description => "collections to shard", @@ -57,7 +58,12 @@ :display_name => "Replicaset_name", :description => "Name of a mongodb replicaset", :default => nil - + attribute "mongodb/enable_rest", :display_name => "Enable Rest", :description => "Enable the ReST interface of the webserver" + +attribute "mongodb/bind_ip", + :display_name => "Bind address", + :description => "MongoDB instance bind address", + :default => nil diff --git a/mongodb/recipes/10gen_repo.rb b/mongodb/recipes/10gen_repo.rb index 5cb6e83..19c1993 100755 --- a/mongodb/recipes/10gen_repo.rb +++ b/mongodb/recipes/10gen_repo.rb @@ -22,15 +22,15 @@ # Sets up the repositories for stable 10gen packages found here: # http://www.mongodb.org/downloads#packages -case node['platform'] -when "debian", "ubuntu" +case node['platform_family'] +when "debian" # Adds the repo: http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages execute "apt-get update" do action :nothing end apt_repository "10gen" do - uri "http://downloads-distro.mongodb.org/repo/debian-sysvinit" + uri "http://downloads-distro.mongodb.org/repo/#{node[:mongodb][:apt_repo]}" distribution "dist" components ["10gen"] keyserver "hkp://keyserver.ubuntu.com:80" @@ -39,7 +39,7 @@ notifies :run, "execute[apt-get update]", :immediately end -when "centos","redhat","fedora","amazon" +when "rhel","fedora" yum_repository "10gen" do description "10gen RPM Repository" url "http://downloads-distro.mongodb.org/repo/redhat/os/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}" diff --git a/mongodb/recipes/default.rb b/mongodb/recipes/default.rb index ca49fec..08c462c 100755 --- a/mongodb/recipes/default.rb +++ b/mongodb/recipes/default.rb @@ -23,7 +23,7 @@ action :install end -needs_mongo_gem = (node.recipes.include?("mongodb::replicaset") or node.recipes.include?("mongodb::mongos")) +needs_mongo_gem = (node.recipe?("mongodb::replicaset") or node.recipe?("mongodb::mongos")) if needs_mongo_gem # install the mongo ruby gem at compile time to make it globally available @@ -33,10 +33,11 @@ Gem.clear_paths end -if node.recipes.include?("mongodb::default") or node.recipes.include?("mongodb") +if node.recipe?("mongodb::default") or node.recipe?("mongodb") # configure default instance mongodb_instance "mongodb" do mongodb_type "mongod" + bind_ip node['mongodb']['bind_ip'] port node['mongodb']['port'] logpath node['mongodb']['logpath'] dbpath node['mongodb']['dbpath'] diff --git a/mongodb/recipes/replicaset.rb b/mongodb/recipes/replicaset.rb index 81093cf..5ac0595 100755 --- a/mongodb/recipes/replicaset.rb +++ b/mongodb/recipes/replicaset.rb @@ -20,7 +20,7 @@ include_recipe "mongodb" # if we are configuring a shard as a replicaset we do nothing in this recipe -if !node.recipes.include?("mongodb::shard") +if !node.recipe?("mongodb::shard") mongodb_instance "mongodb" do mongodb_type "mongod" port node['mongodb']['port'] diff --git a/mongodb/recipes/shard.rb b/mongodb/recipes/shard.rb index e05b834..5278c0e 100755 --- a/mongodb/recipes/shard.rb +++ b/mongodb/recipes/shard.rb @@ -27,7 +27,7 @@ action [:disable, :stop] end -is_replicated = node.recipes.include?("mongodb::replicaset") +is_replicated = node.recipe?("mongodb::replicaset") # we are not starting the shard service with the --shardsvr diff --git a/mongodb/templates/default/mongodb.default.erb b/mongodb/templates/default/mongodb.default.erb index d1ea140..54816dd 100755 --- a/mongodb/templates/default/mongodb.default.erb +++ b/mongodb/templates/default/mongodb.default.erb @@ -6,6 +6,9 @@ NAME="<%= @name %>" DAEMON_OPTS="" +<% if @bind_ip -%> +DAEMON_OPTS="$DAEMON_OPTS --bind_ip <%= @bind_ip %>" +<% end -%> <%= @port ? "DAEMON_OPTS=\"$DAEMON_OPTS --port #{@port}\"" : "" %> <%= @dbpath ? "DAEMON_OPTS=\"$DAEMON_OPTS --dbpath #{@dbpath}\"" : "" %> <%= @logpath ? "DAEMON_OPTS=\"$DAEMON_OPTS --logpath #{@logpath}\"" : "" %> diff --git a/mongodb/templates/freebsd/mongodb.default.erb b/mongodb/templates/freebsd/mongodb.default.erb index 4f72749..421dbbd 100755 --- a/mongodb/templates/freebsd/mongodb.default.erb +++ b/mongodb/templates/freebsd/mongodb.default.erb @@ -3,6 +3,9 @@ DAEMON_OPTS="--fork" +<% if @bind_ip -%> +DAEMON_OPTS="$DAEMON_OPTS --bind_ip <%= @bind_ip %>" +<% end -%> <%= @port ? "DAEMON_OPTS=\"$DAEMON_OPTS --port #{@port}\"" : "" %> <%= @dbpath ? "DAEMON_OPTS=\"$DAEMON_OPTS --dbpath #{@dbpath}\"" : "" %> <%= @logpath ? "DAEMON_OPTS=\"$DAEMON_OPTS --logpath #{@logpath}\"" : "" %>