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

Update mongodb to fe562b86f388a6d107bb1f3cb3b32a3978f59c2a #154

Merged
merged 1 commit into from
Dec 1, 2014
Merged
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
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod 'module-data',
:git => 'https://github.com/ripienaar/puppet-module-data.git'

mod 'mongodb',
:commit => '0518f864afcce2ebb79f1f2edab5de323c811af7',
:commit => 'fe562b86f388a6d107bb1f3cb3b32a3978f59c2a',
:git => 'https://github.com/puppetlabs/puppetlabs-mongodb.git'

mod 'mysql',
Expand Down
3 changes: 1 addition & 2 deletions mongodb/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Gemfile.lock
metadata.json
*.idea
*.swp
*.tmp
tmp/
pkg/
spec/fixtures/manifests
.rspec_system/
.vagrant/
.vagrant/
74 changes: 0 additions & 74 deletions mongodb/CHANGELOG

This file was deleted.

94 changes: 94 additions & 0 deletions mongodb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
##2014-11-25 - Release 0.9.0
###Summary

This release has a number of new parameters, support for 2.6, improved providers, and several bugfixes.

####Features
- New parameters: `mongodb::globals`
- `$service_ensure`
- `$service_enable`
- New parameters: `mongodb`
- `$quiet`
- New parameters: `mongodb::server`
- `$service_ensure`
- `$service_enable`
- `$quiet`
- `$config_content`
- Support for mongodb 2.6
- Reimplement `mongodb_user` and `mongodb_database` provider
- Added `mongodb_conn_validator` type

####Bugfixes
- Use hkp for the apt keyserver
- Fix mongodb database existance check
- Fix `$server_package_name` problem (MODULES-690)
- Make sure `pidfilepath` doesn't have any spaces
- Providers need the client command before they can work (MODULES-1285)

##2014-05-27 - Release 0.8.0
###Summary

This feature features a rewritten mongodb_replset{} provider, includes several
important bugfixes, ruby 1.8 support, and two new features.

####Features
- Rewritten mongodb_replset{}, featuring puppet resource support, prefetching,
and flushing.
- Add Ruby 1.8 compatibility.
- Adds `syslog`, allowing you to configure mongodb to send all logging to the hosts syslog.
- Add mongodb::replset, a wrapper class for hiera users.
- Improved testing!

####Bugfixes
- Fixes the package names to work since 10gen renamed them again.
- Fix provider name in the README.
- Disallow `nojournal` and `journal` to be set at the same time.
- Changed - to = for versioned install on Ubuntu.

##2014-1-29 - Release 0.7.0
###Summary

Added Replica Set Type and Provider

##2014-1-17 - Release 0.6.0
###Summary

Added support for installing MongoDB client on
RHEL family systems.

##2014-01-10 Release 0.5.0
###Summary

Added types for providers for Mongo users and databases.

##2013-12 Release 0.4.0

Major refactoring of the MongoDB module. Includes a new 'mongodb::globals'
that consolidates many shared parameters into one location. This is an
API-breaking release in anticipation of a 1.0 release.

##2013-10-31 - Release 0.3.0
###Summary

Adds a number of parameters and fixes some platform
specific bugs in module deployment.

##2013-09-25 - Release 0.2.0
###Summary

This release fixes a duplicate parameter.

####Bugfixes
- Fix a duplicated parameter.

##2012-07-13 - Release 0.1.0
- Add support for RHEL/CentOS
- Change default mongodb install location to OS repo

##2012-05-29 - Release 0.0.2
- Fix Modulefile typo.
- Remove repo pin.
- Update spec tests and add travis support.

##2012-05-03 - Release 0.0.1
- Initial Release.
1 change: 0 additions & 1 deletion mongodb/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ group :test, :development do
gem 'simplecov', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'vagrant-wrapper', :require => false
end

if puppetversion = ENV['PUPPET_VERSION']
Expand Down
12 changes: 0 additions & 12 deletions mongodb/Modulefile

This file was deleted.

16 changes: 14 additions & 2 deletions mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class {'::mongodb::server':

For Red Hat family systems, the client can be installed in a similar fashion:

```
puppet class {'::mongodb::client':}
```puppet
class {'::mongodb::client':}
```

Note that for Debian/Ubuntu family systems the client is installed with the
Expand Down Expand Up @@ -335,6 +335,14 @@ set name as an argument to this set. All hosts must have the same set name.
#####`rest`
Set to true to enable a simple REST interface. Default: false

#####`quiet`
Runs the mongod or mongos instance in a quiet mode that attempts to limit the
amount of output. This option suppresses : "output from database commands, including drop, dropIndexes, diagLogging, validate, and clean", "replication activity", "connection accepted events" and "connection closed events".
Default: false

> For production systems this option is **not** recommended as it may make tracking
problems during particular connections much more difficult.

#####`slowms`
Sets the threshold for mongod to consider a query “slow” for the database profiler.
Default: 100 ms
Expand Down Expand Up @@ -411,6 +419,7 @@ The maximum amount of two second tries to wait MongoDB startup. Default: 10

```puppet
mongodb_user { testuser:
username => 'testuser',
ensure => present,
password_hash => mongodb_password('testuser', 'p@ssw0rd'),
database => testdb,
Expand All @@ -419,6 +428,9 @@ mongodb_user { testuser:
require => Class['mongodb::server'],
}
```
#####`username`
Name of the mongodb user.

#####`password_hash`
Hex encoded md5 hash of "$username:mongo:$password".

Expand Down
54 changes: 54 additions & 0 deletions mongodb/lib/puppet/provider/mongodb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Puppet::Provider::Mongodb < Puppet::Provider

# Without initvars commands won't work.
initvars
commands :mongo => 'mongo'

# Optional defaults file
def self.mongorc_file
if File.file?("#{Facter.value(:root_home)}/.mongorc.js")
"load('#{Facter.value(:root_home)}/.mongorc.js'); "
else
nil
end
end

def mongorc_file
self.class.mongorc_file
end

# Mongo Command Wrapper
def self.mongo_eval(cmd, db = 'admin')
if mongorc_file
cmd = mongorc_file + cmd
end

out = mongo([db, '--quiet', '--eval', cmd])

out.gsub!(/ObjectId\(([^)]*)\)/, '\1')
out
end

def mongo_eval(cmd, db = 'admin')
self.class.mongo_eval(cmd, db)
end

# Mongo Version checker
def self.mongo_version
@@mongo_version ||= self.mongo_eval('db.version()')
end

def mongo_version
self.class.mongo_version
end

def self.mongo_24?
v = self.mongo_version
! v[/^2\.4\./].nil?
end

def mongo_24?
self.class.mongo_24?
end

end
38 changes: 21 additions & 17 deletions mongodb/lib/puppet/provider/mongodb_database/mongodb.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
Puppet::Type.type(:mongodb_database).provide(:mongodb) do
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mongodb'))
Puppet::Type.type(:mongodb_database).provide(:mongodb, :parent => Puppet::Provider::Mongodb) do

desc "Manages MongoDB database."

defaultfor :kernel => 'Linux'

commands :mongo => 'mongo'

def block_until_mongodb(tries = 10)
begin
mongo('--quiet', '--eval', 'db.getMongo()')
rescue => e
debug('MongoDB server not ready, retrying')
sleep 2
if (tries -= 1) > 0
retry
else
raise e
def self.instances
require 'json'
dbs = JSON.parse mongo_eval('printjson(db.getMongo().getDBs())')

dbs['databases'].collect do |db|
new(:name => db['name'],
:ensure => :present)
end
end

# Assign prefetched dbs based on name.
def self.prefetch(resources)
dbs = instances
resources.keys.each do |name|
if provider = dbs.find { |db| db.name == name }
resources[name].provider = provider
end
end
end

def create
mongo(@resource[:name], '--quiet', '--eval', "db.dummyData.insert({\"created_by_puppet\": 1})")
mongo_eval('db.dummyData.insert({"created_by_puppet": 1})', @resource[:name])
end

def destroy
mongo(@resource[:name], '--quiet', '--eval', 'db.dropDatabase()')
mongo_eval('db.dropDatabase()', @resource[:name])
end

def exists?
block_until_mongodb(@resource[:tries])
mongo("--quiet", "--eval", 'db.getMongo().getDBNames()').chomp.split(",").include?(@resource[:name])
!(@property_hash[:ensure] == :absent or @property_hash[:ensure].nil?)
end

end
Loading