diff --git a/definitions/mongodb.rb b/definitions/mongodb.rb index 7b0a801..70cc801 100644 --- a/definitions/mongodb.rb +++ b/definitions/mongodb.rb @@ -20,7 +20,6 @@ # define :mongodb_instance, - :mongodb_type => 'mongod', :action => [:enable, :start], :logpath => '/var/log/mongodb/mongodb.log', :dbpath => '/data', @@ -28,11 +27,6 @@ :replicaset => nil, :notifies => [] do - # TODO: this is the only remain use of params[:mongodb_type], is it still needed? - unless %w(mongod shard configserver mongos).include?(params[:mongodb_type]) - fail ArgumentError, ":mongodb_type must be 'mongod', 'shard', 'configserver' or 'mongos'; was #{params[:mongodb_type].inspect}" - end - # Make changes to node['mongodb']['config'] before copying to new_resource. Chef 11 appears to resolve the attributes # with precedence while Chef 10 copies to not (TBD: find documentation to support observed behavior). if node['mongodb']['is_mongos'] diff --git a/recipes/configserver.rb b/recipes/configserver.rb index fe0313f..c7c471a 100644 --- a/recipes/configserver.rb +++ b/recipes/configserver.rb @@ -19,6 +19,7 @@ # limitations under the License. # +# ensure these are stored by using node.set, not merely node.default node.set['mongodb']['is_configserver'] = true node.set['mongodb']['cluster_name'] = node['mongodb']['cluster_name'] node.set['mongodb']['shard_name'] = node['mongodb']['shard_name'] @@ -29,10 +30,10 @@ # http://docs.mongodb.org/manual/reference/configuration-options/#sharded-cluster-options # we still explicitly set the port and small files. mongodb_instance node['mongodb']['instance_name'] do - mongodb_type 'configserver' - port node['mongodb']['config']['port'] - logpath node['mongodb']['config']['logpath'] - dbpath node['mongodb']['config']['dbpath'] - enable_rest node['mongodb']['config']['rest'] - smallfiles node['mongodb']['config']['smallfiles'] + is_configserver true + cluster_name node['mongodb']['cluster_name'] + shard_name node['mongodb']['shard_name'] + port node['mongodb']['config']['port'] + logpath node['mongodb']['config']['logpath'] + dbpath node['mongodb']['config']['dbpath'] end diff --git a/recipes/default.rb b/recipes/default.rb index 7da16a2..4206d2b 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -37,12 +37,9 @@ if allow_mongodb_instance_run mongodb_instance node['mongodb']['instance_name'] do - mongodb_type 'mongod' bind_ip node['mongodb']['config']['bind_ip'] port node['mongodb']['config']['port'] logpath node['mongodb']['config']['logpath'] dbpath node['mongodb']['config']['dbpath'] - enable_rest node['mongodb']['config']['rest'] - smallfiles node['mongodb']['config']['smallfiles'] end end diff --git a/recipes/mongos.rb b/recipes/mongos.rb index 8ba39af..7b05cde 100644 --- a/recipes/mongos.rb +++ b/recipes/mongos.rb @@ -19,6 +19,7 @@ # limitations under the License. # +# ensure these are stored by using node.set, not merely node.default node.set['mongodb']['is_mongos'] = true node.set['mongodb']['shard_name'] = node['mongodb']['shard_name'] node.override['mongodb']['instance_name'] = 'mongos' @@ -51,11 +52,10 @@ end mongodb_instance node['mongodb']['instance_name'] do - mongodb_type 'mongos' - port node['mongodb']['config']['port'] - logpath node['mongodb']['config']['logpath'] - dbpath node['mongodb']['config']['dbpath'] - configservers configsrvs - enable_rest node['mongodb']['config']['rest'] - smallfiles node['mongodb']['config']['smallfiles'] + is_mongos true + shard_name node['mongodb']['shard_name'] + port node['mongodb']['config']['port'] + logpath node['mongodb']['config']['logpath'] + dbpath node['mongodb']['config']['dbpath'] + configservers configsrvs end diff --git a/recipes/replicaset.rb b/recipes/replicaset.rb index b2d547d..9130f9c 100644 --- a/recipes/replicaset.rb +++ b/recipes/replicaset.rb @@ -17,6 +17,7 @@ # limitations under the License. # +# ensure these are stored by using node.set, not merely node.default node.set['mongodb']['is_replicaset'] = true node.set['mongodb']['cluster_name'] = node['mongodb']['cluster_name'] @@ -33,12 +34,11 @@ unless node['mongodb']['is_shard'] mongodb_instance node['mongodb']['instance_name'] do - mongodb_type 'mongod' + is_replicaset true + cluster_name node['mongodb']['cluster_name'] port node['mongodb']['config']['port'] logpath node['mongodb']['config']['logpath'] dbpath node['mongodb']['config']['dbpath'] replicaset node - enable_rest node['mongodb']['config']['rest'] - smallfiles node['mongodb']['config']['smallfiles'] end end diff --git a/recipes/shard.rb b/recipes/shard.rb index e331ed2..a9a8b85 100644 --- a/recipes/shard.rb +++ b/recipes/shard.rb @@ -19,6 +19,7 @@ # limitations under the License. # +# ensure these are stored by using node.set, not merely node.default node.set['mongodb']['is_shard'] = true node.set['mongodb']['shard_name'] = node['mongodb']['shard_name'] node.set['mongodb']['is_replicaset'] = node['mongodb']['is_replicaset'] @@ -30,11 +31,12 @@ # commandline option because right now this only changes the port it's # running on, and we are overwriting this port anyway. mongodb_instance node['mongodb']['instance_name'] do - mongodb_type 'shard' - port node['mongodb']['config']['port'] - logpath node['mongodb']['config']['logpath'] - dbpath node['mongodb']['config']['dbpath'] - replicaset node if node['mongodb']['is_replicaset'] - enable_rest node['mongodb']['config']['rest'] - smallfiles node['mongodb']['config']['smallfiles'] + is_shard true + is_replicaset node['mongodb']['is_replicaset'] + port node['mongodb']['config']['port'] + logpath node['mongodb']['config']['logpath'] + dbpath node['mongodb']['config']['dbpath'] + shard_name node['mongodb']['shard_name'] + cluster_name node['mongodb']['cluster_name'] + replicaset node if node['mongodb']['is_replicaset'] end