Skip to content

Commit

Permalink
Add new classes for installing Ops Manager on a target machine. Updat…
Browse files Browse the repository at this point in the history
…e the README with how to use it. Write 2 tests to make sure things are installed correctly.

Modify files in line with the recommendations made in the PR.

mongodb-mms for the package name or there are problems the second time the package is installed

remove trailing whitespace

Have to put the template in opsmanager.pp for it to have access to the variables?

Fix the template's new line problems?

Remove opsmanager_version and replace it with the option to use a different download_url.

Fix line 45

Update params so that the ops_manager hostname defaults to http. This should be done with a protocol param maybe.

Add a protocol parameter so that the opsmanager_url can be built correctly.

Linting fix

Make it so the full URL can be provided instead of protocol, hostname and port

Change how the user and group are decided because by default opsmanager creates the user and group mongodb-mms, not mongodb.

set package provider type for opsmanager package install from source URL

Add new classes for installing Ops Manager on a target machine. Update the README with how to use it. Write 2 tests to make sure things are installed correctly.

Modify files in line with the recommendations made in the PR.

mongodb-mms for the package name or there are problems the second time the package is installed

remove trailing whitespace

Have to put the template in opsmanager.pp for it to have access to the variables?

Fix the template's new line problems?

Remove opsmanager_version and replace it with the option to use a different download_url.

Fix line 45

Update params so that the ops_manager hostname defaults to http. This should be done with a protocol param maybe.

Add a protocol parameter so that the opsmanager_url can be built correctly.

Linting fix

Make it so the full URL can be provided instead of protocol, hostname and port

Change how the user and group are decided because by default opsmanager creates the user and group mongodb-mms, not mongodb.

Rebase onto master to resolve conflicts.

Re-add a variable that was blown away

parameter ensure should only accept values present, absent and installed. booleans aren't used any more

mail transport can either be smtp or smtps

Update with feedback from 10/20/18

Use notifies, change ensure, update enums for certain variables, update tests to reflect notifies, add config class.

Rebase onto master

Remove reassignment of . Add an else in case versioncmp(fact('puppetversion'),'5.4.0') > 1

Corrections for feedback from 10/29

Remove all Opsmanager specific globals from globals.pp

opsmanager::params doesn't need to inherit globals anymore.

Missing service provider

Spec update
  • Loading branch information
claycogg committed Nov 7, 2018
1 parent 8cc8a4f commit c44f03d
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 1 deletion.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The MongoDB module manages mongod server installation and configuration of the
mongod daemon. For the time being it supports only a single MongoDB server
instance, without sharding functionality.

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

## Setup

### What MongoDB affects
Expand All @@ -39,6 +41,8 @@ instance, without sharding functionality.
* MongoDB client.
* MongoDB sharding support (mongos)
* MongoDB apt/yum repository.
* Ops Manager package.
* Ops Manager configuration files.

### Beginning with MongoDB

Expand Down Expand Up @@ -135,6 +139,30 @@ mongodb::db { 'testdb':
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'.

### Ops Manager

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

```puppet
class {'mongodb::opsmanager':
opsmanager_url => 'http://opsmanager.yourdomain.com'
mongo_uri => 'mongodb://yourmongocluster:27017,
from_email_addr => 'opsmanager@yourdomain.com',
reply_to_email_addr => 'replyto@yourdomain.com',
admin_email_addr => 'admin@yourdomain.com',
$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](#class-mongodbopsmanager).
There are also some settings that can be configured in `mongodb::globals`.

## Reference

### Classes
Expand All @@ -144,6 +172,7 @@ Unsafe plain text password could be used with 'password' parameter instead of 'p
* `mongodb::client`: Installs the MongoDB client shell (for Red Hat family systems)
* `mongodb::globals`: Configure main settings in a global way
* `mongodb::mongos`: Installs and configure Mongos server (for sharding support)
* `mongodb::opsmanager`: Installs and configure Ops Manager

#### Private classes
* `mongodb::repo`: Manage MongoDB software repository
Expand All @@ -156,6 +185,8 @@ Unsafe plain text password could be used with 'password' parameter instead of 'p
* `mongodb::mongos::config`: Configures Mongos configuration files
* `mongodb::mongos::install`: Install Mongos software packages
* `mongodb::mongos::service`: Manages Mongos service
* `mongodb::opsmanager::install` : Install Ops Manager software package
* `mongodb::opsmanager::service` : Manages Ops Manager (mongodb-mms) service

#### Class: mongodb::globals
*Note:* most server specific defaults should be overridden in the `mongodb::server`
Expand Down Expand Up @@ -623,6 +654,22 @@ Plain-text user password (will be hashed)
##### `roles`
Array with user roles. Default: ['dbAdmin']

##### `opsmanager_url`
The fully qualified url where opsmanager runs. Must include the port. Ex:
'http://opsmanager.yourdomain.com:8080'

##### `opsmanager_mongo_uri`
Full URI where the Ops Manager application mongodb server(s) can be found. Default: 'mongodb://127.0.0.1:27017'

##### `ca_file`
Ca file for secure connection to backup agents.

##### `pem_key_file`
Pem key file containing the cert and private key used for secure connections to backup agents.

##### `pem_key_password`
The password to the pem key file.

### Providers

#### Provider: mongodb_database
Expand Down
52 changes: 52 additions & 0 deletions manifests/opsmanager.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This installs Ops Manager. See README.md for more info.

class mongodb::opsmanager (
String[1] $user = $mongodb::opsmanager::params::user,
String[1] $group = $mongodb::opsmanager::params::group,
Enum['running', 'stopped'] $ensure = $mongodb::opsmanager::params::ensure,
String[1] $package_name = $mongodb::opsmanager::params::package_name,
String[1] $package_ensure = $mongodb::opsmanager::params::package_ensure,
Boolean $service_enable = $mongodb::opsmanager::params::service_enable,
Boolean $service_manage = $mongodb::opsmanager::params::service_manage,
String[1] $service_name = $mongodb::opsmanager::params::service_name,
Stdlib::Httpurl $download_url = $mongodb::opsmanager::params::download_url,
String[1] $mongo_uri = $mongodb::opsmanager::params::mongo_uri,
Stdlib::Httpurl $opsmanager_url = $mongodb::opsmanager::params::opsmanager_url,
String[1] $client_certificate_mode = 'None',
String[1] $from_email_addr = 'from@yourdomain.com',
String[1] $reply_to_email_addr = 'replyto@yourdomain.com',
String[1] $admin_email_addr = 'admin@yourdomain.com',
String[1] $email_dao_class = 'com.xgen.svc.core.dao.email.JavaEmailDao', #AWS SES: com.xgen.svc.core.dao.email.AwsEmailDao or SMTP: com.xgen.svc.core.dao.email.JavaEmailDao
Enum['smtp','smtps'] $mail_transport = 'smtp', #smtp or smtps
String[1] $smtp_server_hostname = 'your-email-relay.email.com', # if email_dao_class is SMTP: Email hostname your email provider specifies.
String[1] $smtp_server_port = '25', #if email_dao_class is SMTP: Email hostname your email provider specifies.
Boolean $ssl = false,
Boolean $ignore_ui_setup = true,
#optional settings
Optional[String[1]] $ca_file = $mongodb::opsmanager::params::ca_file,
Optional[String[1]] $pem_key_file = $mongodb::opsmanager::params::pem_key_file,
Optional[String[1]] $pem_key_password = $mongodb::opsmanager::params::pem_key_password,
Optional[String[1]] $user_svc_class = undef, # Default: com.xgen.svc.mms.svc.user.UserSvcDb External Source: com.xgen.svc.mms.svc.user.UserSvcCrowd or Internal Database: com.xgen.svc.mms.svc.user.UserSvcDb
Optional[Integer] $snapshot_interval = undef, # Default: 24
Optional[Integer] $snapshot_interval_retention = undef, # Default: 2
Optional[Integer] $snapshot_daily_retention = undef, # Default: 0
Optional[Integer] $snapshot_weekly_retention = undef, # Default: 2
Optional[Integer] $snapshot_monthly_retention = undef, # Default: 1
Optional[Integer] $versions_directory = undef, # Linux default: /opt/mongodb/mms/mongodb-releases/

) inherits mongodb::opsmanager::params {

contain mongodb::opsmanager::install
contain mongodb::opsmanager::config
contain mongodb::opsmanager::service

if ($mongo_uri == 'mongodb://127.0.0.1:27017') {
include mongodb::server
}

if ($ensure == 'running') {
Class['mongodb::opsmanager::install']
~> Class['mongodb::opsmanager::config']
~> Class['mongodb::opsmanager::service']
}
}
14 changes: 14 additions & 0 deletions manifests/opsmanager/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# PRIVATE CLASS: do not call directly
class mongodb::opsmanager::config {
$user = $mongodb::opsmanager::user
$group = $mongodb::opsmanager::group

file { '/opt/mongodb/mms/conf/conf-mms.properties':
ensure => file,
owner => $user,
group => $group,
mode => '0644',
content => epp('mongodb/opsmanager/conf-mms.properties.epp'),
}
}
41 changes: 41 additions & 0 deletions manifests/opsmanager/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# PRIVATE CLASS: do not call directly
class mongodb::opsmanager::install {
#assert_private("You are calling a private class mongodb::opsmanager::install.")
$package_ensure = $mongodb::opsmanager::package_ensure
$package_name = $mongodb::opsmanager::package_name
$download_url = $mongodb::opsmanager::download_url

case $package_ensure {
'absent': {
$my_package_ensure = 'absent'
$file_ensure = 'absent'
}
default: {
$my_package_ensure = $package_ensure
$file_ensure = 'present'
}
}

if versioncmp(fact('puppetversion'),'5.4.0') < 0 {
case $facts['os']['family'] {
'RedHat': {
$my_provider = 'rpm'
}
'Debian': {
$my_provider = 'dpkg'
}
default: {
warning("The ${module_name} module might not work on ${facts['os']['family']}. Sensible defaults will be attempted.")
$my_provider = undef
}
}
} else {
$my_provider = undef
}

package { $package_name:
ensure => $my_package_ensure,
source => $download_url,
provider => $my_provider,
}
}
20 changes: 20 additions & 0 deletions manifests/opsmanager/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# PRIVATE CLASS: do not use directly
class mongodb::opsmanager::params {
$ensure = 'running'
$user = 'mongodb-mms'
$group = 'mongodb-mms'
$package_name = 'mongodb-mms'
$service_name = 'mongodb-mms'
$service_manage = true
$service_enable = true
$service_ensure = 'running'
$service_status = undef
$opsmanager_url = undef
$service_provider = undef
$download_url = 'https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-4.0.1.50101.20180801T1117Z-1.x86_64.rpm'
$mongo_uri = 'mongodb://127.0.0.1:27017'
$package_ensure = 'present'
$ca_file = undef
$pem_key_file = undef
$pem_key_password = undef
}
19 changes: 19 additions & 0 deletions manifests/opsmanager/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# PRIVATE CLASS: do not call directly
class mongodb::opsmanager::service {
#assert_private("You are calling a private class mongodb::opsmanager::service.")
$service_ensure = $mongodb::opsmanager::ensure
$service_manage = $mongodb::opsmanager::service_manage
$service_enable = $mongodb::opsmanager::service_enable
$service_name = $mongodb::opsmanager::service_name
$service_provider = $mongodb::opsmanager::service_provider
$service_status = $mongodb::opsmanager::service_status

if $service_manage {
service { $service_name:
ensure => $service_ensure,
enable => $service_enable,
provider => $service_provider,
status => $service_status,
}
}
}
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$pidfilemode = pick($mongodb::globals::pidfilemode, '0644')
$manage_pidfile = pick($mongodb::globals::manage_pidfile, true)

$version = $mongodb::globals::version
$version = $mongodb::globals::version

$config_data = undef

Expand Down
20 changes: 20 additions & 0 deletions spec/classes/ops_manager_install_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

describe 'mongodb::opsmanager::install' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }

describe 'it should create package' do
let(:pre_condition) { ["class mongodb::opsmanager { $download_url = 'https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-4.0.1.50101.20180801T1117Z-1.x86_64.rpm' $package_ensure = 'present' $user = 'mongodb' $group = 'mongodb' $package_name = 'mongodb-mms' }", 'include mongodb::opsmanager'] }

it {
is_expected.to contain_package('mongodb-mms').with(ensure: 'present',
name: 'mongodb-mms')
}

it { is_expected.to compile.with_all_deps }
end
end
end
end
37 changes: 37 additions & 0 deletions spec/classes/ops_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'spec_helper'

describe 'mongodb::opsmanager' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }

let(:params) do
{
opsmanager_url: 'http://localhost:8080'
}
end

describe 'with defaults' do
it { is_expected.to compile.with_all_deps }

it {
is_expected.to contain_class('mongodb::opsmanager::install').
that_notifies('Class[mongodb::opsmanager::config]')
}

it {
is_expected.to contain_class('mongodb::opsmanager::config').
that_notifies('Class[mongodb::opsmanager::service]')
}

it { is_expected.to contain_class('mongodb::opsmanager::service') }

it { is_expected.to contain_service('mongodb') }

it { is_expected.to contain_service('mongodb-mms') }

it { is_expected.to create_package('mongodb-mms').with_ensure('present') }
end
end
end
end
Loading

0 comments on commit c44f03d

Please sign in to comment.