Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

Commit

Permalink
update mongodb cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel250 committed Mar 24, 2013
1 parent 81b94de commit 0a0d8db
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 23 deletions.
4 changes: 3 additions & 1 deletion mongodb/attributes/default.rb
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
14 changes: 9 additions & 5 deletions mongodb/definitions/mongodb.rb
Expand Up @@ -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"

Expand All @@ -31,6 +31,7 @@
service_action = params[:action]
service_notifies = params[:notifies]

bind_ip = params[:bind_ip]
port = params[:port]

logpath = params[:logpath]
Expand Down Expand Up @@ -93,6 +94,7 @@
"name" => name,
"config" => configfile,
"configdb" => configserver,
"bind_ip" => bind_ip,
"port" => port,
"logpath" => logfile,
"dbpath" => dbpath,
Expand Down Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions 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"
Expand All @@ -14,30 +15,30 @@
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

attribute "mongodb/dbpath",
: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.",
Expand All @@ -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",
Expand All @@ -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
8 changes: 4 additions & 4 deletions mongodb/recipes/10gen_repo.rb
Expand Up @@ -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"
Expand All @@ -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'}"
Expand Down
5 changes: 3 additions & 2 deletions mongodb/recipes/default.rb
Expand Up @@ -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
Expand All @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion mongodb/recipes/replicaset.rb
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion mongodb/recipes/shard.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions mongodb/templates/default/mongodb.default.erb
Expand Up @@ -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}\"" : "" %>
Expand Down
3 changes: 3 additions & 0 deletions mongodb/templates/freebsd/mongodb.default.erb
Expand Up @@ -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}\"" : "" %>
Expand Down

0 comments on commit 0a0d8db

Please sign in to comment.