Git Product home page Git Product logo

puppet-mongodb's Introduction

mongodb puppet module

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores License

Table of Contents

  1. Overview
  2. Module Description - What does the module do?
  3. Setup - The basics of getting started with mongodb
  4. Usage - Configuration options and additional functionality
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Overview

Installs MongoDB on RHEL/Ubuntu/Debian/SLES from community/enterprise repositories or alternatively from custom repositories.

Module Description

The MongoDB module manages mongod server installation and configuration of the mongod daemon.

The MongoDB module also manages mongos, Ops Manager and the mongdb-mms setup.

Setup

What MongoDB affects

  • MongoDB packages.
  • MongoDB configuration files.
  • MongoDB services.
  • MongoDB apt/yum/zypper repository.

Beginning with MongoDB

If you want a server installation with the default options you can run include mongodb::server. If you need to customize configuration options you need to do the following:

class {'mongodb::server':
  port    => 27018,
  verbose => true,
}

To install client with default options run include mongodb::client

To override the default mongodb repo version you need the following:

class {'mongodb::globals':
  repo_version => '4.4',
}
-> class {'mongodb::server': }
-> class {'mongodb::client': }

If you have a custom Mongodb repository you can opt out of repo management:

class {'mongodb::globals':
  manage_package_repo => false,
}
-> class {'mongodb::server': }
-> class {'mongodb::client': }

Usage

Most of the interaction for the server is done via mongodb::server. For more options please have a look at mongodb::server. There is also mongodb::globals to set some global settings, on its own this class does nothing.

Create MongoDB database

To install MongoDB server, create database "testdb" and user "user1" with password "pass1".

class {'mongodb::server':
  auth => true,
}

mongodb::db { 'testdb':
  user          => 'user1',
  password_hash => 'a15fbfca5e3a758be80ceaf42458bcd8',
}

Parameter 'password_hash' is hex encoded md5 hash of "user1:mongo:pass1". Unsafe plain text password could be used with 'password' parameter instead of 'password_hash'.

Sharding

If one plans to configure sharding for a Mongo deployment, the module offer the mongos installation. mongos can be installed the following way :

class {'mongodb::mongos' :
  configdb => ['configsvr1.example.com:27018'],
}

Ops Manager

To install Ops Manager and have it run with a local MongoDB application server do the following:

class {'mongodb::opsmanager':
  opsmanager_url        => 'http://opsmanager.yourdomain.com'
  mongo_uri             => 'mongodb://yourmongocluster:27017,
  from_email_addr       => '[email protected]',
  reply_to_email_addr   => '[email protected]',
  admin_email_addr      => '[email protected]',
  $smtp_server_hostname => 'email-relay.yourdomain.com'
}

The default settings will not set useful email addresses. You can also just run include mongodb::opsmanager and then set the emails later.

Ops Manager Usage

Most of the interaction for the server is done via mongodb::opsmanager. For more options please have a look at mongodb::opsmanager.

Limitations

This module has been tested on:

  • Debian 10.* (Buster)
  • Debian 11.* (Bookworm)
  • Ubuntu 20.04.0 LTS (Focal Fossa)
  • RHEL 7/8
  • CentOS 7/8

Development

This module is maintained by Vox Pupuli. Voxpupuli welcomes new contributions to this module, especially those that include documentation and rspec tests. We are happy to provide guidance if necessary.

Please see CONTRIBUTING for more details.

Authors

  • Puppetlabs Module Team
  • Voxpupuli Team

We would like to thank everyone who has contributed issues and pull requests to this module. A complete list of contributors can be found on the GitHub Contributor Graph for the puppet-mongodb module.

puppet-mongodb's People

Contributors

alexjfisher avatar bastelfreak avatar bmjen avatar bond-os avatar cmurphy avatar cyberious avatar davids avatar deathborn avatar dgolja avatar dhoppe avatar ekohl avatar emilienm avatar eputnam avatar fatmcgav avatar fbrehm avatar h-haaks avatar hunner avatar jvginkel avatar leopoiroux avatar nanliu avatar poloz-lab avatar root-expert avatar smortex avatar spredzy avatar stevenpost avatar tomritserveldt avatar tphoney avatar traylenator avatar wyardley avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-mongodb's Issues

mongodb_user provider does not support creating the user in multiple databases

The mongodb_user provider does not support creating the user in multiple databases and including the resource more than gives a duplicate resources error.

I believe the mongodb_user provider should accept an array for the database parameter and create the user in each one. Something like

mongodb_user { testuser:
  name          => 'testuser',
  ensure        => present,
  password_hash => mongodb_password('testuser', 'p@ssw0rd'),
  database      => [ 'foo', 'bar' ]
  roles         => ['readWrite', 'dbAdmin'],
  tries         => 10,
  require       => Class['mongodb::server'],
}

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5
  • Ruby: 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
  • Distribution: Centos 7
  • Module version: 2.1.2

Config out of sorts with 10-gen install on Ubuntu

It looks as though the config is out of sorts with the 10-gen installation. For instance the default config file installed is named /etc/mongodb.conf insted of mongod.conf

There are more of these things. Would it be helpful if i send a diff?

Add parameter for key server

Currently the keyserver is hardcoded to keyserver.ubuntu.com, i want to make this so it is a parameter to globals that can be passed so it can be overriden either by hiera or by being passed when the class it called.

repl_set provider

I think something is wrong with the replica set provider. My config does not work following the example. Indeed I tryed to execute the replicaset.pp test included in the module and ends with the same result:

Error: Execution of '/usr/bin/mongo --quiet --host mongo1:27017 --eval printjson(rs.initiate({ _id: "rsmain", members: [ mongo1:27017 ] }))' returned 252: Thu Jan 30 12:27:41.825 SyntaxError: Unexpected token :

Error: /Stage[main]//Node[mongo1]/Mongodb_replset[rsmain]/ensure: change from ab
sent to present failed: Execution of '/usr/bin/mongo --quiet --host mongo1:27017 --eval printjson(rs.initiate({ _id: "rsmain", members: [ mongo1:27017 ] }))' returned 252: Thu Jan 30 12:27:41.825 SyntaxError: Unexpected token :

10gen apt repository causing a dependency cycle

Running puppet 2.7.18 on Ubuntu 13.04

I've included the mongodb class in my manifest with:

  class{'mongodb':
    enable_10gen => true,
  }

I have previous apt repositories in my configuration that install correctly.

This results in the following error in when running puppet:

err: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[apt::key 7F0CEB10 present] => Apt::Key[Add key: 7F0CEB10 from Apt::Source 10gen] => File[10gen.list] => Exec[apt_update] => Class[Apt::Update] => Stage[pre] => Stage[main] => Class[Mongodb::Sources::Apt] => Apt::Source[10gen] => File[10gen.list])

Here's the dependency cycle graph:

puppetcycle

Could not find scope for mongodb::params

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.1
  • Ruby: 2.1.9p490 (puppet bundled)
  • Distribution: Debian Jessie 8.10
  • Module version: 1.1.0

How to reproduce (e.g Puppet code you use)

enable manage_package_repo in globals.pp

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Resource Statement, Could not find scope for mongodb::params at /etc/puppetlabs/code/environments/production/modules/mongodb/manifests/globals.pp:47:5 on node host

What behaviour did you expect instead

I expected the apt source list to be created by puppet.

Output log

see above

Any additional information you'd like to impart

n/a

Puppet execution hangs when mongo in a bad state

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.3.3
  • Ruby: 2.4.2p198
  • Distribution: RHEL7.4
  • Module version: v1.1.0

How to reproduce (e.g Puppet code you use)

  class { '::mongodb::globals':
    server_package_name => 'mongodb-org-server',
    client_package_name => 'mongodb-org-shell',
    mongos_package_name => 'mongodb-org-mongos',
    bind_ip             => [ '0.0.0.0' ],
  }
  class { '::mongodb::server':
    auth            => true,
    verbose         => false,
    nohttpinterface => true,
    replset         => "logs-repl",
    replset_members => ['mongodb1', 'mongodb2'],
    keyfile         => '/etc/mongodb-keyfile',
    key             => ...,
    create_admin    => ...admin,
    admin_password  => ...ass,
    store_creds     => true,
  }
  class { '::mongodb::client': }

What are you seeing

Puppet agent execution is failing outright with the error below.

What behaviour did you expect instead

I would expect Puppet to show a warning and continue with applying the remainder of a policy if it cannot connect to a mongo instance or fail to retrieve a related fact.

Output log

Error: Failed to apply catalog: Could not evaluate MongoDB shell command: printjson(db.getMongo().getDBs())

Any additional information you'd like to impart

Stumbled across this whilst trying to update an unrelated module on a mongo server. The mongo service was in a recovering state, so the mongo shell commands weren't returning. Stopping the mongod service and/or moving the .mongorc.js aside failed to persuade the policy to continue.

Provider mongodb_shard cause catalog compilation because query sh.status() returned '406 unexpected token'

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.4.0
  • Ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
  • Distribution: CentOS 7.4
  • Module version: commit fa03a58

How to reproduce (e.g Puppet code you use)

class {'mongodb::globals':
    manage_package_repo => true,
    version   => '3.6.3',
}

class {'mongodb::server':
    configsvr => true,
    bind_ip   => ['127.0.0.1', $facts['ipaddress_enp0s8']],
    replset   => 'config0'
}

contain '::mongodb::client'

class {'mongodb::mongos':
    configdb => ['config0/mons101:27019', 'mons102:27019', 'mons103:27019'],
}

mongodb_replset {'config0':
    members => ['mons101:27019', 'mons102:27019', 'mons103:27019'],
}

mongodb_shard { 'rs0' :
    member => 'rs0/mons104:27018',
}

What are you seeing

Error: Failed to apply catalog: 409: unexpected token at 'activemongoses:"3.6.3":3autosplit:Currentlyenabled:yesbalancer:Currentlyenabled:yesCurrentlyrunning:noFailedbalancerroundsinlast5attempts:0MigrationResultsforthelast24hours:Norecentmigrations],"databases":[{"_id":"config","primary":"config","partitioned":true}]}'

What behaviour did you expect instead

The shard is working correctly, however the return code has just conflicted the Puppet. Return code handling was expected to ensure the idempotency of the module.
Look shard running correctly:

--- Sharding Status ---
  sharding version: {
  	"_id" : 1,
  	"minCompatibleVersion" : 5,
  	"currentVersion" : 6,
  	"clusterId" : ObjectId("5a99cd43b4a227922e7eb03b")
  }
  shards:
  active mongoses:
        "3.6.3" : 3
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled:  yes
        Currently running:  no
        Failed balancer rounds in last 5 attempts:  0
        Migration Results for the last 24 hours:
                No recent migrations
  databases:
        {  "_id" : "config",  "primary" : "config",  "partitioned" : true }

Output log

Debug: Storing state
Debug: Stored state in 0.02 seconds
Error: Failed to apply catalog: 409: unexpected token at 'activemongoses:"3.6.3":3autosplit:Currentlyenabled:yesbalancer:Currentlyenabled:yesCurrentlyrunning:noFailedbalancerroundsinlast5attempts:0MigrationResultsforthelast24hours:Norecentmigrations],"databases":[{"_id":"config","primary":"config","partitioned":true}]}'

Any additional information you'd like to impart

Nothing.

fix acceptance tests

Even with the work done to get tests passing w/ modulesync, there are still some failing tests and pending tests in the acceptance tests, and acceptance tests aren't yet running in Travis.

Tasks for release 2.0.0

  • Mark failing acceptance tests as pending, and re-enable in Travis
  • convert parameters to data types - #406
  • Rip out deprecated parameters - #406
  • replace anchor pattern with contain / class ordering
  • document parameters with Puppet Strings
  • Rip out Mongo 2.x related code
  • reformat spec tests to be more readable ?
  • Fix acceptance tests

cc @ekohl

package version override broken with yum

migrated from JIRA

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: puppet-agent-1.10.3-1, puppetserver-2.7.2-1
  • Ruby:
  • Distribution: CentOS 7.3
  • Module version: 0.17.0

I set version in global.pp to 3.4
$version = '3.4',
the client puppet run updates the yum repo correctly to manage this version
[mongodb]
baseurl=http://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/
enabled=1
gpgcheck=0
name=MongoDB/10gen Repository
showing the parameter is parsed and taken correctly,
however this also impacts the package name on the client install,

Output log

Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install mongodb-org-server-3.4' returned 1: Error: Nothing to do
Error: /Stage[main]/Mongodb::Server::Install/Package[mongodb_server]/ensure: change from purged to 3.4 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install mongodb-org-server-3.4' returned 1: Error: Nothing to do

Any additional information you'd like to impart

the package is mongodb-org-server
====================================================== N/S matched: mongodb-org ======================================================
mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage)
mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router
mongodb-org-server.x86_64 : MongoDB database server
mongodb-org-shell.x86_64 : MongoDB shell client
mongodb-org-tools.x86_64 : MongoDB tools
This package is available - with the right version coming from the correct yum repo configured by puppet from the mongodb repo
Available Packages
Name : mongodb-org-server
Arch : x86_64
Version : 3.4.5
Release : 1.el7
Size : 20 M
Repo : mongodb
Summary : MongoDB database server
URL : http://www.mongodb.org
License : AGPL 3.0
Description : MongoDB is built for scalability, performance and high availability, scaling from single server deployments to large,
: complex multi-site architectures. By leveraging in-memory computing, MongoDB provides high performance for both reads
: and writes. MongoDB’s native replication and automated failover enable enterprise-grade reliability and operational
: flexibility.
:
: MongoDB is an open-source database used by companies of all sizes, across all industries and for a wide variety of
: applications. It is an agile database that allows schemas to change quickly as applications evolve, while still
: providing the functionality developers expect from traditional databases, such as secondary indexes, a full query
: language and strict consistency.
:
: MongoDB has a rich client ecosystem including hadoop integration, officially supported drivers for 10 programming
: languages and environments, as well as 40 drivers supported by the user community.
:
: MongoDB features:
: * JSON Data Model with Dynamic Schemas
: * Auto-Sharding for Horizontal Scalability
: * Built-In Replication for High Availability
: * Rich Secondary Indexes, including geospatial
: * TTL indexes
: * Text Search
: * Aggregation Framework & Native MapReduce
:
: This package contains the MongoDB server software, default configuration files, and systemd service files.
The only way around this is to hardcode the package name in the parameters to be mongdb-org, while this will technically work, it defaults the object of not doing this as the external repos reference mongodb-org packages, the distro packages versions are mongodb-server without the -org suffix.
Reading this bug the debian package manager had this problem a long time ago, but it looks as if it's either a regression or was never addressed for yum (or I've just not understood the usage of the module).

Existence of /root/.mongorc.js triggers mongod restart

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.10
  • Ruby: 2.1.9 (bundled)
  • Distribution: RHEL 7.4
  • Module version: 2.0.0

How to reproduce (e.g Puppet code you use)

Set up a default mongodb install with the module, e.g.

class { '::mongodb::globals':
  manage_package_repo => true,
}
class { '::mongodb::server': }
class { '::mongodb::client': }

After puppet has set up everything, run mongo as root on the server to get a mongodb shell.
Exit the mongodb shell, then trigger a puppet run.

What are you seeing

Puppet sees the (empty) /root/.mongorc.js file, deletes it, and restarts mongod.

What behaviour did you expect instead

mongod should not be restarted whenever someone starts a mongo shell on the server as root.

Output log

Info: /Stage[main]/Mongodb::Server::Config/File[/root/.mongorc.js]: Filebucketed /root/.mongorc.js to puppet with sum d41d8cd98f00b204e9800998ecf8427e
Notice: /Stage[main]/Mongodb::Server::Config/File[/root/.mongorc.js]/ensure: removed
Info: Class[Mongodb::Server::Config]: Scheduling refresh of Class[Mongodb::Server::Service]
Info: Class[Mongodb::Server::Service]: Scheduling refresh of Service[mongodb]
Notice: /Stage[main]/Mongodb::Server::Service/Service[mongodb]: Triggered 'refresh' from 1 events

Any additional information you'd like to impart

create admin and repl set fail with password

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet:
  • Ruby:
  • Distribution: CentOS 7
  • Module version: 1.0.0

Any additional information you'd like to impart

migrated from JIRA

How to reproduce (e.g Puppet code you use)

The relevant settings for the setup

  class { 'mongodb::server':
    port           => 27017,
    dbpath         => '/data/mongo',
    bind_ip        => ['0.0.0.0'],
    auth           => true,
    keyfile        => '/opt/mongo/mongo-keyfile',
    replset        => 'rsmain',
    replset_config => {
      'rsmain' => {
        ensure  => present,
        members => ["${ip1}:27017", "${ip2}:27017"]
      }
    }
    ,
    create_admin   => true,
    admin_password => "test",
 }

i use the mongodb own repos
'https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/'

Output log

Error: /Mongodb_user[User admin on db admin]: Only one of 'password_hash' or 'password' should be provided

Fact "mongodb_is_master" fails on mongodb clients

I use this module through the Pulp module, on CentOS 7. Given that my mongodb database is located on another server, Pulp module only installs the client with include ::mongodb::client
The problem comes when Puppet evaluates facts: mongodb_is_master fact tries to open a config file which does not exist on a client:

if %w[mongo mongod].all? { |m| Facter::Util::Resolution.which m }
file = mongod_conf_file
config = YAML.load_file(file)

That produces the following error:
Error: Facter: error while resolving custom fact "mongodb_is_master": No such file or directory @ rb_sysopen - /etc/mongodb.conf

I suppose this "if" on line 15 should be modified to not match the "mongo client only" case, given that the related "else" results in 'not_installed', which would fit.

invalid byte sequence in US-ASCII

Hi,

thanks for your work.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 3.7.5
  • Distribution: debian 8
  • Module version: v1.1.0

What are you seeing

invalid byte sequence in US-ASCII in mongo.rb

I jump from 0.17.0 to v1.1.0 and I got
'invalid byte sequence in US-ASCII,change from {md5}38efb877a97fd0e162252e4681d65c46 to {md5}b9939023cdbe3bd5d3352e1db68017be failed: invalid byte sequence in US-ASCII,invalid byte sequence in US-ASCII,change from {md5}85a74779d028eff9872831590a7693ab to {md5}8e29585c9aab0293f8ad5e52f15d9eb5 failed: invalid byte sequence in US-ASCII,removed,Finished catalog run in 7.81 seconds'

on all my machine.

in script 'mongodb_replset.rb' and/or 'mongo.rb'

any help ?

could not find parent resource type

I get this error when I include the module via vagrant (puppet version 3.3.2):

Error: Could not find parent resource type 'mongodb::params' of type hostclass i
n production at /tmp/vagrant-puppet/modules-0/puppetlabs-mongodb/manifests/init.
pp:33 on node localhost.localdomain

Can you please tell me if I am missing anything? This is what I do in my puppet file:

import "puppetlabs-mongodb"

class { 'mongodb':
enable_10gen => true,
}

"Unknown variable 'mongodb::params::journal'" error when 'manage_package => true'

When updating our Profiles module to support Puppet 4.x, we started seeing test failures on the mongodb class:

error during compilation: Evaluation Error: Unknown variable: 'mongodb::params::journal'.

With the assistance of Johnson Earls on Slack spotted that params.pp doesn't set $fork or $journal when $manage_package => true on RHEL OS'.
https://github.com/voxpupuli/puppet-mongodb/blob/master/manifests/params.pp#L120-L121

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: ~> 4.0
  • Ruby: 2.1.9
  • Distribution: CentOS 7
  • Module version: 1.1.0

Changing a user's password doesn't work

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.9
  • Ruby: 2.3.1p112
  • Distribution: Ubuntu 16.04
  • Module version: 2.0.0

How to reproduce (e.g Puppet code you use)

  1. Create a database user
mongodb_user { "foobar":
    username      => 'foo',
    database      => 'bar',
    password      => '12345',
    roles         => ['readWrite'],
  }
  1. Change Puppet code to use "abcde" as password
  2. Try to authenticate to MongoDB using the new password

What are you seeing

After Step 1 authentication succeeds. But after changing to another password it fails:

root@test:~# mongo -u foo -p abcde bar
MongoDB shell version: 2.6.10
connecting to: bar
2018-02-05T09:35:31.723+0100 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1287
exception: login failed

Trying to authenticate using the previous password works:

root@test:~# mongo -u foo -p abcde bar
MongoDB shell version: 2.6.10
connecting to: bar
>

What behaviour did you expect instead

Authentication using the new password should work.

Any additional information

When running Puppet Agent at step 2 there are no error messages. According to the debug output the password change is done using the following command:
Debug: Executing '/usr/bin/mongo bar --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.runCommand({"updateuser": "foo","pwd": "abcde","digestpassword": true})'

If I run the command manually I get the error "no such cmd: updateuser":

root@test-pu-mongodb:~# mongo bar
MongoDB shell version: 2.6.10
connecting to: bar
> db.runCommand({"updateuser": "foo","pwd": "abcde","digestpassword": true});
{
        "ok" : 0,
        "errmsg" : "no such cmd: updateuser",
        "code" : 59,
        "bad cmd" : {
                "updateuser" : "foo",
                "pwd" : "bar",
                "digestpassword" : true
        }
}

Comparing the password hash within MongoDB with the expected one shows that it is still using the one for the old password.

Is_master fact not working with SSL

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.8
  • Ruby: 2.0.0p648
  • Distribution: Centos 7
  • Module version: 2.1.0

How to reproduce (e.g Puppet code you use)

Try to create user on a mongodb instance with SSL

What are you seeing

User is not being created due to the fact that

2018-03-19T09:38:40.123-0400 W NETWORK [thread1] The server certificate does not match the host name. Hostname: 127.0.0.1 does not match SAN(s): *.domain.net domain.net
true

is being output from

mongo admin --quiet --host 127.0.0.1:9011 --sslAllowInvalidHostnames --ssl --sslPEMKeyFile /etc/ssl/mongodb.pem --sslCAFile /etc/ssl/mongo-ca.pem --eval "load('/root/.mongorc.js'); db.isMaster().ismaster"

so Is_master is not being set to true

What behaviour did you expect instead

Is_master becomes true and users are made

Output log

Any additional information you'd like to impart

Extending the replicaset provider to handle more options e.g. priority, voting, etc.

Hey @fcharlier, @hogepodge,

I'm thinking about creating a new feature branch in ordet to support more replica set options with the intention of getting merged backed upstream.

At the moment i'm thinking about modifying the current provider so it supports the following usage:

mongodb_replset { ‘rsmain’:
  ensure => ‘present’,
  members => {
   ‘host1’ => { 
     hostname      => ‘host1.internal’,
     port          => ‘27017’,
     arbiter_only  => false,
     build_indexes => false,
     hidden        => false,
     priority      => ‘1',
     tags          => undef,
     slave_delay   => ‘0',
     votes         => ‘1’
   },

 ‘host2’ => { 
   hostname      => ‘host2.internal’,

   port          => ‘27017’,
   priority      => ‘0.5'
 },

 ‘host3’ => { 
   hostname      => ‘host3.internal’,

   port          => ‘27017’,
   priority      => ‘0.5'
   }
  }
}

Unfortunately as you can immediately see it breaks the current usage:

mongodb_replset { rsmain:
  ensure  => present,
  members => ['host1:27017', 'host2:27017', 'host3:27017']
}

Is this correct way forward or would you suggest another?

@actionjack

running puppet service does not find mongo client

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.9
  • Ruby: ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
  • Distribution: RHEL7 (u4)
  • Module version: puppet-mongodb (v2.1.0)

How to reproduce (e.g Puppet code you use)

class {'::mongodb::globals':
manage_package_repo => true,
manage_package => true,
server_package_name => 'rh-mongodb32-mongodb-server',
client_package_name => 'rh-mongodb32-mongodb',
service_name => 'rh-mongodb32-mongod',
user => 'mongodb',
group => 'mongodb',
require => Repos::Yum['rhel-server-rhscl-7-rpms'],
}
->
class {'::mongodb::server':
config => '/etc/opt/rh/rh-mongodb32/mongod.conf',
dbpath => '/var/opt/rh/rh-mongodb32/lib/mongodb',
ipv6 => false,
logappend => true,
logpath => '/var/opt/rh/rh-mongodb32/log/mongodb/mongod.log',
pidfilepath => '/var/opt/rh/rh-mongodb32/run/mongodb/mongod.pid',
port => 27017,
system_logrotate => 'reopen',
}
->
class{'::mongodb::client':
require => File['/etc/mongodb.conf'],
}

Create profile file withthe following content.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/rh-mongodb32/root/lib64
export PATH=$PATH:/opt/rh/rh-mongodb32/root/usr/bin

What are you seeing

When using the puppet service, this error occurs:
Failed to apply catalog: Could not evaluate MongoDB shell command: printjson(db.getMongo().getDBs())

When running "puppet agent -t" from the command line, the run succeeds, because when running from the commandline it uses the environment variables.

What behaviour did you expect instead

Output log

Failed to apply catalog: Could not evaluate MongoDB shell command: printjson(db.getMongo().getDBs())

Any additional information you'd like to impart

Error: 'versioncmp' parameter 'a' expects a String value, got Undef

With module version 1.0.0 I get the following error with puppet 4 on server and puppet 3 on client (in process of upgrading nodes):

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: {"message":"Server Error: Evaluation Error: Error while evaluating a Function Call, 'versioncmp' parameter 'a' expects a String value, got Undef at mongodb/manifests/params.pp:217:10 on node ...","issue_kind":"RUNTIME_ERROR","stacktrace":["Warning: The 'stacktrace' property is deprecated and will be removed in a future version of Puppet. For security reasons, stacktraces are not returned with Puppet HTTP Error responses."]}
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
``

mongodb_replset doesn't work

I'm setting up a simple dev replica set and I'm getting the following:

Mongodb_replset[rsmain]/ensure: change from absent to present failed: Execution of '/usr/bin/mongo --quiet --host localhost:27017 --eval printjson(rs.initiate({ _id: "rsmain", members: [ localhost:27017,localhost:27018,localhost:27019 ] }))' returned 252: Tue Feb  4 00:19:03.956 SyntaxError: Unexpected token :

From the docs: http://docs.mongodb.org/manual/reference/replica-configuration/ it looks like the members need to be objects, not just host:port strings.

running this within the client worked:

> rs.initiate({ _id: "rsmain", members: [ {_id: 0, host: "localhost:27017"}, {_id: 1, host: "localhost:27018"}, {_id: 2, host: "localhost:27019"} ] })
{
    "info" : "Config now saved locally.  Should come online in about a minute.",
    "ok" : 1
}

this was the invocation within puppet:

$replset = 'rsmain'

  mongodb_replset { $replset:
    ensure  => present,
    members => ['localhost:27017', 'localhost:27018', 'localhost:27019'],
    require => [
      Supervisor::Service['mongodb2'],
      Supervisor::Service['mongodb3'],
    ],
  }

running:

$ puppet --version
2.7.19
MongoDB shell version: 2.4.9
$ mongod --version
db version v2.4.9
Tue Feb 4 00:34:25.229 git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c

10gen repo handling doesn't work

i'm getting:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Mongodb::Globals] is already declared; cannot redeclare at /etc/puppet/modules/mystuff/manifests/mymongo.pp

mymongo.pp contains:

class mystuff::mymongo {
    class {'::mongodb::globals':
          manage_package_repo => true,
    }-> 
    class {'::mongodb::server': }-> 
    class {'::mongodb::client': }
}

puppet master and node are on v3.4.3

holding it wrong?

error authentication when admin user is set

There is no way to use this puppet class if an admin user is set on my mongodb server.

Explanation
I installed my mongodb server by this puppet class and I set an admin user like this:

mongodb_user { root:
    ensure               => present,
    password_hash => mongodb_password('root', 'root'),
    database           => admin,
    roles                  => [ "read", "readWrite", "dbAdmin", "userAdmin", "clusterAdmin", "readAnyDatabase", "readWriteAnyDatabase", "userAdminAnyDatabase", "dbAdminAnyDatabase"],
    tries                   => 10,
    require               => Class['mongodb::server'],
  }

Now I got an authentication error.

ability to create a user administrator

It would be nice if you could fully enable authentication by not only specifying the auth parameter with

class { "mongodb": 
  auth=>true,
}

but if you could additionally specify user administrators with something like:

mongodb::user_administrator { "username":
  password => "aReallyGoodPassword",
  roles => ["userAdminAnyDatabase"],
}

Any reason not to include this in here?

user creation idempotency issues

See, e.g., https://tickets.puppetlabs.com/browse/MODULES-3749


Info: Applying configuration version '1471431010'
--
Warning: User info is available only from master host
Warning: User creation is available only from master host
Notice: /Stage[main]/Mongodb::Server/Mongodb::Db[admin]/Mongodb_user[User admin on db admin]/ensure: created
Warning: User creation is available only from master host
Notice: /Stage[main]/Main/Node[mongo1]/Mongodb::Db[kannel]/Mongodb_user[User kannel on db kannel]/ensure: created
Warning: User creation is available only from master host
Notice: /Stage[main]/Main/Node[mongo1]/Mongodb::Db[kannel_ll]/Mongodb_user[User kannel_ll on db kannel_ll]/ensure: created
Notice: Applied catalog in 0.80 seconds

This may be hard to fix while we're still supporting 2.x

duplicate definition of parameter $mms_name

the release version of the module on puppet forge has a duplicate parameter definition of $mms_name in init.pp

...
$nssize = undef,
$mms_token = undef,
$mms_name = undef,
$mms_name = undef,
$mms_interval = undef,
$slave = undef,
...

Auth in mongod 3.6

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.1.9
  • Ruby: 2.1.9
  • Distribution: CentOS/7
  • Module version: 2.0.0

How to reproduce (e.g Puppet code you use)

class { '::mongodb::globals':
    bind_ip => [ '0.0.0.0' ],
    version => '3.6.1',
    manage_package_repo => true,
    repo_location => 'https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.6/x86_64/',
  }

  -> class { '::mongodb::client': }

  -> class { '::mongodb::server':
    verbose => true,
    directoryperdb => true,
    manage_pidfile => false,

    auth => true,
    store_creds => true,
    create_admin => true,
    admin_username => "$admin_username",
    admin_password => "$admin_password",
  }

What are you seeing

Debug: Prefetching mongodb resources for mongodb_database
Debug: Executing: '/bin/mongo admin --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); printjson(db.getMongo().getDBs())'
Debug: Request failed: 'Execution of '/bin/mongo admin --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); printjson(db.getMongo().getDBs())' returned 252: Error: Authentication failed.
2018-01-10T13:35:14.082+0000 E QUERY    [thread1] Error: listDatabases failed:{
	"ok" : 0,
	"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, $db: \"admin\" }",
	"code" : 13,
	"codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:65:1

What behaviour did you expect instead

I would have expected the module to configure Mongo 3.6, enable authentication and create the admin account. It appears the account must be created with mongo running without auth enabled, once an admin account is created, it should be then started with auth enabled.

Output log

As per 'What are you seeing'

Any additional information you'd like to impart

N/A

Was the name change intentional?

Looks like the module name changed from puppetlabs-mongdb to puppet-mongodb with 1.1.0. Was this intentional? If so, there should have been a major version number increase as it breaks dependencies with other modules.

Ability to set 'replSet' and 'rest' in config-file

I've looked over this module, but I cannot find anywhere to set replica set variables.

I would manually need to add 'replSet = XXX' and 'rest = true' to mongodb.conf after installing the package. I see a lot of settings in init.pp but not any of these two.

Did I miss anything or is this not a supported feature?

Notice on every run for password_hash

Short problem description:
On each and every run I get 'notice' output for the defined password_hash.
Example:

Notice: /Stage[main]/Mongodb::Server/Mongodb::Db[admin]/Mongodb_user[User admin on db admin]/password_hash: defined 'password_hash' as 'ahash'
Notice: /Stage[main]/Profiles::Mongodb/Mongodb_user[devuser]/password_hash: defined 'password_hash' as 'anotherhash'

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.5
  • Ruby: 2.0.0p648
  • Distribution: RHEL 7
  • Module version: 1.1.0

How to reproduce (e.g Puppet code you use)

 if $auth {
    # Set auth enabled server vars
    # Default auth vars
    $default_auth_vars = {
      auth           => true,
      create_admin   => true,
      store_creds    => true,
    }
    # Take hiera data information
    $hiera_auth_vars = lookup('mongoadmin', Hash, hash, {
      admin_roles    => 'root',
      admin_username => 'admin',
      admin_password => '',
    })
    # Build authvars var
    $authvars = deep_merge($default_auth_vars,$hiera_auth_vars)
    #defaults for user creation
    $user_defaults = {
      ensure  => present,
      tries   => 3,
      require => Class['mongodb::server'],
    }
    # Get users and database config directly from hiera
    create_resources('mongodb_user', lookup('mongousers', Hash), $user_defaults)
  }
  else {
    # If auth is failed
    # set auth disabled server vars (default behaviour for legacy)
    $authvars = {
      auth           => false,
      create_admin   => false,
    }
  }

What are you seeing

Notice: /Stage[main]/Mongodb::Server/Mongodb::Db[admin]/Mongodb_user[User admin on db admin]/password_hash: defined 'password_hash' as 'ahash'
Notice: /Stage[main]/Profiles::Mongodb/Mongodb_user[devuser]/password_hash: defined 'password_hash' as 'anotherhash'

What behaviour did you expect instead

no notice output

Output log

Notice: /Stage[main]/Mongodb::Server/Mongodb::Db[admin]/Mongodb_user[User admin on db admin]/password_hash: defined 'password_hash' as 'ahash'
Notice: /Stage[main]/Profiles::Mongodb/Mongodb_user[devuser]/password_hash: defined 'password_hash' as 'anotherhash'

Any additional information you'd like to impart

run mongodb --quiet with quiet => true

It would be great if I could configure this module to run the mongo daemon --quiet.

Is there a way to do that?

This currently does not work. Is there such a parameter?

  class { 'mongodb':
    enable_10gen => true, 
    quiet => true,
    dbpath => "${::db_path}/mongodb",
    version => $mongo_version,
    replSet => $::replica_set_name,
    keyFile => $mongo_keyfile,
  }

I know verbose defaults to false, but this level of logging is still much more than when running mongod --quiet

Thanks!

Example of usage with sharding

Can you provide an example of how to configure a sharded cluster using the module? Is it possible to use it on a single machine, i.e. with separate processes?

apt-transport-https required on Ubuntu when installing version >= 3.0.0.

When using this module to install mongodb on Ubuntu 16.04 using this config:

class {'::mongodb::globals':
manage_package_repo => true,
server_package_name => mongodb-org,
service_name => mongod,
version => 3.4.10,
}->
class {'::mongodb::server':
auth => true,
bind_ip => ['127.0.0.1'],
}

The repo that is added uses https, but a default installation of Ubuntu 16.04 server doesn't have apt-transport-https installed and so apt-get update fails to download indexes from the new repo. Altering the URLs in mongodb/manifests/repo.pp to use http instead of https works as expected.

Mongo 3.6 database creation problem.

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.7.1
  • Ruby: ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux]
  • Distribution: CentOS Linux release 7.3.1611 (Core)
  • Module version: 2.1.0

How to reproduce (e.g Puppet code you use)

class { 'mongodb::globals':
    manage_package_repo => false,
    manage_package      => true,
    manage_pidfile      => false,
    version             => '3.6.3-1.el7'
}
-> class {'::mongodb::client':
}
-> class { '::mongodb::server':
    bind_ip        => ['0.0.0.0'],
    dbpath         => '/opt/mongo',
    logpath        => '/opt/mongo/mongod.log',
    quiet          => false,
    auth           => true,
    restart        => false,
    create_admin   => true,
    admin_username => 'admin',
    admin_password => 'admin-password',
    admin_roles    => ['root'],
    store_creds    => true,
    slowms         => 5000,
    replset        => 'replset-name',
    storage_engine => 'wiredTiger',
    keyfile        => '/etc/mongod.key',
    key            => 'thisismykey'
}

What are you seeing

Error: Failed to apply catalog: 757: unexpected token at '{
	"databases" : [
		{
			"name" : "admin",
			"sizeOnDisk" : 147456,
			"empty" : false
		},
		{
			"name" : "config",
			"sizeOnDisk" : 20480,
			"empty" : false
		},
		{
			"name" : "local",
			"sizeOnDisk" : 430080,
			"empty" : false
		}
	],
	"totalSize" : 598016,
	"ok" : 1,
	"operationTime" : Timestamp(1521039021, 1),
	"$clusterTime" : {
		"clusterTime" : Timestamp(1521039021, 1),
		"signature" : {
			"hash" : BinData(0,"/DRm1gxEZjw9JUrKBA4MQjYUX+c="),
			"keyId" : "6532767491985244161"
		}
	}
}
'

What behaviour did you expect instead

No error

Output log

Debug: Connected to mongodb in 0.001244489 seconds.
Debug: Prefetching mongodb resources for mongodb_database
Debug: Executing: '/bin/mongo admin --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); printjson(db.getMongo().getDBs())'
Debug: Storing state
Debug: Stored state in 0.07 seconds
Error: Failed to apply catalog: 757: unexpected token at '{
	"databases" : [
		{
			"name" : "admin",
			"sizeOnDisk" : 147456,
			"empty" : false
		},
		{
			"name" : "config",
			"sizeOnDisk" : 20480,
			"empty" : false
		},
		{
			"name" : "local",
			"sizeOnDisk" : 425984,
			"empty" : false
		}
	],
	"totalSize" : 593920,
	"ok" : 1,
	"operationTime" : Timestamp(1521037711, 1),
	"$clusterTime" : {
		"clusterTime" : Timestamp(1521037711, 1),
		"signature" : {
			"hash" : BinData(0,"FRWHMhjGcgspM2BcnZXQJTrGNiE="),
			"keyId" : "6532767491985244161"
		}
	}
}
'
Debug: Dynamically-bound server lookup failed, falling back to report_server setting
Debug: Dynamically-bound port lookup failed; falling back to report_port setting

Any additional information you'd like to impart

I have found that mongo 3.6.3

printjson(db.getMongo().getDBs())

show different output than earlier versions:
in 3.6.3 is:

{
	"databases" : [
		{
			"name" : "admin",
			"sizeOnDisk" : 200704,
			"empty" : false
		},
		{
			"name" : "config",
			"sizeOnDisk" : 20480,
			"empty" : false
		},
		{
			"name" : "local",
			"sizeOnDisk" : 442368,
			"empty" : false
		}
	],
	"totalSize" : 696320,
	"ok" : 1,
	"operationTime" : Timestamp(1521042451, 1),
	"$clusterTime" : {
		"clusterTime" : Timestamp(1521042451, 1),
		"signature" : {
			"hash" : BinData(0,"LvZA6qFyfPVoVSGqZlWDRf7XrBs="),
			"keyId" : NumberLong("6532767491985244161")
		}
	}
}

3.2 is:

{
    "databases" : [
        {
            "name" : "admin",
            "sizeOnDisk" : 200704,
            "empty" : false
        },
        {
            "name" : "local",
            "sizeOnDisk" : 7976722432,
            "empty" : false
        }
    ],
    "totalSize" : 320729784320,
    "ok" : 1
}

Change in puppet/modules/mongodb/lib/puppet/provider/mongodb_database/mongodb.rb as below helps.

- dbs = JSON.parse mongo_eval('printjson(db.getMongo().getDBs())')
+ dbs = JSON.parse mongo_eval('printjson(db.getMongo().getDBs())').gsub!(%r{\w+\((\d+).+?\)}, '\1')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.