Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb_instance: remove mongodb_type, update recipes #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions definitions/mongodb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@
#

define :mongodb_instance,
:mongodb_type => 'mongod',
:action => [:enable, :start],
:logpath => '/var/log/mongodb/mongodb.log',
:dbpath => '/data',
:configservers => [],
: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']
Expand Down
7 changes: 4 additions & 3 deletions recipes/configserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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'
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']
enable_rest node['mongodb']['config']['rest']
smallfiles node['mongodb']['config']['smallfiles']
end
3 changes: 0 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions recipes/mongos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -51,11 +52,10 @@
end

mongodb_instance node['mongodb']['instance_name'] do
mongodb_type 'mongos'
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
enable_rest node['mongodb']['config']['rest']
smallfiles node['mongodb']['config']['smallfiles']
end
6 changes: 3 additions & 3 deletions recipes/replicaset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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
8 changes: 5 additions & 3 deletions recipes/shard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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'
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']
enable_rest node['mongodb']['config']['rest']
smallfiles node['mongodb']['config']['smallfiles']
end