<commit_before>#
# Cookbook Name:: mongodb
# Recipe:: default
#
# Copyright 2011, edelight GmbH
# Authors:
#       <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Add the upstream package repository and install the latest stable package
add_repo "mongodb" do
  url       "http://downloads-distro.mongodb.org/repo/debian-sysvinit"
  distro    "dist"
  repo_area "10gen"
  key_url    "keyserver.ubuntu.com"
  key_string "7F0CEB10"
end

package "mongodb-10gen" do
  action :install
end

needs_mongo_gem = (node.recipes.include?("mongodb::replicaset") or node.recipes.include?("mongodb::mongos"))

if needs_mongo_gem
  gem_package 'mongo' do
    action :nothing
  end.run_action(:install)
  Gem.clear_paths
end

# configure default instance
mongodb_instance "mongodb" do
  mongodb_type "mongod"
  port         node['mongodb']['port']
  logpath      node['mongodb']['logpath']
  dbpath       node['mongodb']['dbpath']
end

<commit_msg>Removed debian specific bits to use the 10gen repo for mongodb, use the distributor's mongodb package instead. Added documentation on how to find all members in a cluster, e.g. to configure a firewall.<commit_after>#
# Cookbook Name:: mongodb
# Recipe:: default
#
# Copyright 2011, edelight GmbH
# Authors:
#       <NAME> <<EMAIL>@edelight.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

package "mongodb" do
  action :install
end

needs_mongo_gem = (node.recipes.include?("mongodb::replicaset") or node.recipes.include?("mongodb::mongos"))

if needs_mongo_gem
  gem_package 'mongo' do
    action :nothing
  end.run_action(:install)
  Gem.clear_paths
end

# configure default instance
mongodb_instance "mongodb" do
  mongodb_type "mongod"
  port         node['mongodb']['port']
  logpath      node['mongodb']['logpath']
  dbpath       node['mongodb']['dbpath']
end

## Firewall configuration ##
#
# in order to find all member nodes of a mongodb cluster you have to run queries
# like:
#    source_nodes = []
#
#    node['mongodb']['client_roles'].each do |client_role|
#      source_nodes += search(:node, "role:#{client_role} AND environment:#{node['environment']}")
#    end
#
#    if !node['mongodb']['cluster_role_prefix'].nil?
#      source_nodes += search(
#        :node,
#        "role:#{node['mongodb']['cluster_role_prefix']}* AND \
#         (NOT ipaddress:#{node['ipaddress']}) AND \
#         environment:#{node['environment']}"
#      )
#    end
##

{'fraction_non_alphanumeric': 0.11231354197133665, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 4.119760479041916, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4196916', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1031, 'n_words': 350}