Skip to content

Commit

Permalink
Added replicaset_name attribute to predefine replicaset names. Howeve…
Browse files Browse the repository at this point in the history
…r for replicated shards this name will still be ignored,

and the name of the replicaset will be generated using 'rs_#{shard_name}'.
  • Loading branch information
Markus Korn committed Oct 24, 2011
1 parent fa596d6 commit e82a6b5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 19 deletions.
3 changes: 2 additions & 1 deletion mongodb/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
default[:mongodb][:logpath] = "/var/log/mongodb"
default[:mongodb][:port] = 27017

# roles
# cluster identifier
default[:mongodb][:client_roles] = []
default[:mongodb][:cluster_name] = nil
default[:mongodb][:replicaset_name] = nil
default[:mongodb][:shard_name] = "default"
18 changes: 14 additions & 4 deletions mongodb/definitions/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,20 @@
configserver_nodes = params[:configserver]

replicaset = params[:replicaset]
begin
replicaset_name = "rs_#{replicaset['mongodb']['shard_name']}" # Looks weird, but we need just some name
rescue
replicaset_name = nil
if type == "shard"
# for replicated shards we autogenerate the replicaset name for each shard
replicaset_name = "rs_#{replicaset['mongodb']['shard_name']}"
else
# if there is a predefined replicaset name we use it,
# otherwise we try to generate one using 'rs_$SHARD_NAME'
replicaset_name = replicaset['mongodb']['replicaset_name']
if replicaset_name.nil?
begin
replicaset_name = "rs_#{replicaset['mongodb']['shard_name']}"
rescue
replicaset_name = nil
end
end
end

if !["mongod", "shard", "configserver", "mongos"].include?(type)
Expand Down
42 changes: 28 additions & 14 deletions mongodb/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"recipes": [

],
"display_name": "Sharded Collections",
"description": "collections to shard"
"description": "collections to shard",
"display_name": "Sharded Collections"
},
"mongodb/shard_name": {
"required": "optional",
Expand All @@ -31,8 +31,8 @@
"recipes": [

],
"display_name": "Shard name",
"description": "Name of a mongodb shard"
"description": "Name of a mongodb shard",
"display_name": "Shard name"
},
"mongodb/dbpath": {
"required": "optional",
Expand All @@ -45,8 +45,8 @@
"recipes": [

],
"display_name": "dbpath",
"description": "Path to store the mongodb data"
"description": "Path to store the mongodb data",
"display_name": "dbpath"
},
"mongodb/logpath": {
"required": "optional",
Expand All @@ -59,8 +59,22 @@
"recipes": [

],
"display_name": "logpath",
"description": "Path to store the logfiles of a mongodb instance"
"description": "Path to store the logfiles of a mongodb instance",
"display_name": "logpath"
},
"mongodb/replicaset_name": {
"required": "optional",
"calculated": false,
"choice": [

],
"default": null,
"type": "string",
"recipes": [

],
"description": "Name of a mongodb replicaset",
"display_name": "Replicaset_name"
},
"mongodb/cluster_name": {
"required": "optional",
Expand All @@ -73,8 +87,8 @@
"recipes": [

],
"display_name": "Cluster Name",
"description": "Name of the mongodb cluster, all nodes of a cluster must have the same name."
"description": "Name of the mongodb cluster, all nodes of a cluster must have the same name.",
"display_name": "Cluster Name"
},
"mongodb/client_roles": {
"required": "optional",
Expand All @@ -89,8 +103,8 @@
"recipes": [

],
"display_name": "Client Roles",
"description": "Roles of nodes who need access to the mongodb instance"
"description": "Roles of nodes who need access to the mongodb instance",
"display_name": "Client Roles"
},
"mongodb/port": {
"required": "optional",
Expand All @@ -103,8 +117,8 @@
"recipes": [

],
"display_name": "Port",
"description": "Port the mongodb instance is running on"
"description": "Port the mongodb instance is running on",
"display_name": "Port"
}
},
"license": "Apache 2.0",
Expand Down
6 changes: 6 additions & 0 deletions mongodb/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
:display_name => "Sharded Collections",
:description => "collections to shard",
:default => {}

attribute "mongodb/replicaset_name",
:display_name => "Replicaset_name",
:description => "Name of a mongodb replicaset",
:default => nil

0 comments on commit e82a6b5

Please sign in to comment.