diff --git a/REFERENCE.md b/REFERENCE.md
index d47dcafd2..e609a288b 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -11,26 +11,26 @@
* [`mongodb::client`](#mongodb--client): Class for installing a MongoDB client shell (CLI).
* [`mongodb::globals`](#mongodb--globals): Class for setting cross-class global overrides. See README.md for more details.
* [`mongodb::mongos`](#mongodb--mongos): This installs a Mongo Shard daemon. See README.md for more details.
-* [`mongodb::mongos::config`](#mongodb--mongos--config): PRIVATE CLASS: do not call directly
-* [`mongodb::mongos::install`](#mongodb--mongos--install): PRIVATE CLASS: do not call directly
-* [`mongodb::mongos::params`](#mongodb--mongos--params): PRIVATE CLASS: do not use directly
-* [`mongodb::mongos::service`](#mongodb--mongos--service): PRIVATE CLASS: do not call directly
* [`mongodb::opsmanager`](#mongodb--opsmanager): This installs Ops Manager
-* [`mongodb::params`](#mongodb--params): PRIVATE CLASS: do not use directly
* [`mongodb::replset`](#mongodb--replset): Wrapper class useful for hiera based deployments
-* [`mongodb::repo`](#mongodb--repo): PRIVATE CLASS: do not use directly
-* [`mongodb::repo::apt`](#mongodb--repo--apt): PRIVATE CLASS: do not use directly
-* [`mongodb::repo::yum`](#mongodb--repo--yum): PRIVATE CLASS: do not use directly
* [`mongodb::server`](#mongodb--server): This installs a MongoDB server. See README.md for more details.
-* [`mongodb::server::config`](#mongodb--server--config): PRIVATE CLASS: do not call directly
-* [`mongodb::server::install`](#mongodb--server--install): PRIVATE CLASS: do not call directly
-* [`mongodb::server::service`](#mongodb--server--service): PRIVATE CLASS: do not call directly
* [`mongodb::shardsvr`](#mongodb--shardsvr): Wrapper class useful for hiera based deployments
#### Private Classes
-* `mongodb::client::params`
+* `mongodb::client::params`: mongodb client params
+* `mongodb::mongos::config`: Manages mongos config
+* `mongodb::mongos::install`: Manages the mongos package
+* `mongodb::mongos::params`: mongos params
+* `mongodb::mongos::service`: Manages the mongos service
+* `mongodb::params`: mongodb params
+* `mongodb::repo`: Manages the mongodb repository
+* `mongodb::repo::apt`: This is a repo class for apt
+* `mongodb::repo::yum`: This is a repo class for yum
* `mongodb::repo::zypper`: This is a repo class for zypper
+* `mongodb::server::config`: Manages mongod config
+* `mongodb::server::install`: Manages the mongod package
+* `mongodb::server::service`: Manages the mongos service
### Defined types
@@ -309,6 +309,8 @@ The following parameters are available in the `mongodb::mongos` class:
* [`service_manage`](#-mongodb--mongos--service_manage)
* [`service_provider`](#-mongodb--mongos--service_provider)
* [`service_name`](#-mongodb--mongos--service_name)
+* [`service_user`](#-mongodb--mongos--service_user)
+* [`service_group`](#-mongodb--mongos--service_group)
* [`service_template`](#-mongodb--mongos--service_template)
* [`service_enable`](#-mongodb--mongos--service_enable)
* [`service_ensure`](#-mongodb--mongos--service_ensure)
@@ -387,6 +389,22 @@ Data type: `Optional[String]`
Default value: `$mongodb::mongos::params::service_name`
+##### `service_user`
+
+Data type: `String`
+
+
+
+Default value: `'mongodb'`
+
+##### `service_group`
+
+Data type: `String`
+
+
+
+Default value: `'mongodb'`
+
##### `service_template`
Data type: `Optional[String[1]]`
@@ -491,262 +509,6 @@ Data type: `Boolean`
Default value: `$mongodb::mongos::params::restart`
-### `mongodb::mongos::config`
-
-PRIVATE CLASS: do not call directly
-
-#### Parameters
-
-The following parameters are available in the `mongodb::mongos::config` class:
-
-* [`package_ensure`](#-mongodb--mongos--config--package_ensure)
-* [`config`](#-mongodb--mongos--config--config)
-* [`config_content`](#-mongodb--mongos--config--config_content)
-* [`config_template`](#-mongodb--mongos--config--config_template)
-* [`service_manage`](#-mongodb--mongos--config--service_manage)
-* [`configdb`](#-mongodb--mongos--config--configdb)
-* [`bind_ip`](#-mongodb--mongos--config--bind_ip)
-* [`port`](#-mongodb--mongos--config--port)
-* [`fork`](#-mongodb--mongos--config--fork)
-* [`pidfilepath`](#-mongodb--mongos--config--pidfilepath)
-* [`logpath`](#-mongodb--mongos--config--logpath)
-* [`unixsocketprefix`](#-mongodb--mongos--config--unixsocketprefix)
-* [`config_data`](#-mongodb--mongos--config--config_data)
-
-##### `package_ensure`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::package_ensure`
-
-##### `config`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::config`
-
-##### `config_content`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::config_content`
-
-##### `config_template`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::config_template`
-
-##### `service_manage`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_manage`
-
-##### `configdb`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::configdb`
-
-##### `bind_ip`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::bind_ip`
-
-##### `port`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::port`
-
-##### `fork`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::fork`
-
-##### `pidfilepath`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::pidfilepath`
-
-##### `logpath`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::logpath`
-
-##### `unixsocketprefix`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::unixsocketprefix`
-
-##### `config_data`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::config_data`
-
-### `mongodb::mongos::install`
-
-PRIVATE CLASS: do not call directly
-
-#### Parameters
-
-The following parameters are available in the `mongodb::mongos::install` class:
-
-* [`package_ensure`](#-mongodb--mongos--install--package_ensure)
-* [`package_name`](#-mongodb--mongos--install--package_name)
-
-##### `package_ensure`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::package_ensure`
-
-##### `package_name`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::package_name`
-
-### `mongodb::mongos::params`
-
-PRIVATE CLASS: do not use directly
-
-### `mongodb::mongos::service`
-
-PRIVATE CLASS: do not call directly
-
-#### Parameters
-
-The following parameters are available in the `mongodb::mongos::service` class:
-
-* [`package_ensure`](#-mongodb--mongos--service--package_ensure)
-* [`service_manage`](#-mongodb--mongos--service--service_manage)
-* [`service_name`](#-mongodb--mongos--service--service_name)
-* [`service_enable`](#-mongodb--mongos--service--service_enable)
-* [`service_ensure`](#-mongodb--mongos--service--service_ensure)
-* [`service_status`](#-mongodb--mongos--service--service_status)
-* [`service_provider`](#-mongodb--mongos--service--service_provider)
-* [`bind_ip`](#-mongodb--mongos--service--bind_ip)
-* [`port`](#-mongodb--mongos--service--port)
-* [`service_template`](#-mongodb--mongos--service--service_template)
-
-##### `package_ensure`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::package_ensure`
-
-##### `service_manage`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_manage`
-
-##### `service_name`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_name`
-
-##### `service_enable`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_enable`
-
-##### `service_ensure`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_ensure`
-
-##### `service_status`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_status`
-
-##### `service_provider`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_provider`
-
-##### `bind_ip`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::bind_ip`
-
-##### `port`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::port`
-
-##### `service_template`
-
-Data type: `Any`
-
-
-
-Default value: `$mongodb::mongos::service_template`
-
### `mongodb::opsmanager`
This installs Ops Manager
@@ -1035,10 +797,6 @@ Data type: `Optional[Integer]`
Default value: `undef`
-### `mongodb::params`
-
-PRIVATE CLASS: do not use directly
-
### `mongodb::replset`
Wrapper class useful for hiera based deployments
@@ -1057,95 +815,6 @@ Data type: `Any`
Default value: `undef`
-### `mongodb::repo`
-
-PRIVATE CLASS: do not use directly
-
-#### Parameters
-
-The following parameters are available in the `mongodb::repo` class:
-
-* [`ensure`](#-mongodb--repo--ensure)
-* [`version`](#-mongodb--repo--version)
-* [`use_enterprise_repo`](#-mongodb--repo--use_enterprise_repo)
-* [`repo_location`](#-mongodb--repo--repo_location)
-* [`proxy`](#-mongodb--repo--proxy)
-* [`proxy_username`](#-mongodb--repo--proxy_username)
-* [`proxy_password`](#-mongodb--repo--proxy_password)
-* [`aptkey_options`](#-mongodb--repo--aptkey_options)
-
-##### `ensure`
-
-Data type: `Variant[Enum['present', 'absent'], Boolean]`
-
-
-
-Default value: `'present'`
-
-##### `version`
-
-Data type: `Optional[String]`
-
-Optional repo version string.
-
-Default value: `undef`
-
-##### `use_enterprise_repo`
-
-Data type: `Boolean`
-
-Boolean value to use enterprise repository. Defaults to false.
-
-Default value: `false`
-
-##### `repo_location`
-
-Data type: `Optional[String]`
-
-Optional location of the repository
-
-Default value: `undef`
-
-##### `proxy`
-
-Data type: `Optional[String]`
-
-
-
-Default value: `undef`
-
-##### `proxy_username`
-
-Data type: `Optional[String]`
-
-
-
-Default value: `undef`
-
-##### `proxy_password`
-
-Data type: `Optional[String]`
-
-
-
-Default value: `undef`
-
-##### `aptkey_options`
-
-Data type: `Optional[String[1]]`
-
-
-
-Default value: `undef`
-
-### `mongodb::repo::apt`
-
-PRIVATE CLASS: do not use directly
-
-### `mongodb::repo::yum`
-
-PRIVATE CLASS: do not use directly
-
### `mongodb::server`
This installs a MongoDB server. See README.md for more details.
@@ -1947,18 +1616,6 @@ Data type: `Array`
Default value: `$mongodb::params::admin_roles`
-### `mongodb::server::config`
-
-PRIVATE CLASS: do not call directly
-
-### `mongodb::server::install`
-
-PRIVATE CLASS: do not call directly
-
-### `mongodb::server::service`
-
-PRIVATE CLASS: do not call directly
-
### `mongodb::shardsvr`
Wrapper class useful for hiera based deployments
diff --git a/data/Debian-10.yaml b/data/Debian-10.yaml
index 142ad3234..b487509e1 100644
--- a/data/Debian-10.yaml
+++ b/data/Debian-10.yaml
@@ -1,3 +1,3 @@
---
-mongodb::globals::version: '4.4.8' # Debian 10 doesn't provide mongodb 3.6.
+mongodb::globals::version: '4.4.29' # Debian 10 doesn't provide mongodb 3.6.
mongodb::globals::manage_package_repo: true # Debian 10 doesn't provide mongodb packages. So manage it!
diff --git a/data/Debian-family.yaml b/data/Debian-family.yaml
new file mode 100644
index 000000000..193d155ea
--- /dev/null
+++ b/data/Debian-family.yaml
@@ -0,0 +1,3 @@
+---
+mongodb::mongos::service_user: 'mongodb'
+mongodb::mongos::service_group: 'mongodb'
diff --git a/data/RedHat-family.yaml b/data/RedHat-family.yaml
new file mode 100644
index 000000000..22614910a
--- /dev/null
+++ b/data/RedHat-family.yaml
@@ -0,0 +1,3 @@
+---
+mongodb::mongos::service_user: 'mongod'
+mongodb::mongos::service_group: 'mongod'
diff --git a/manifests/client/params.pp b/manifests/client/params.pp
index bbc4d07ea..554345997 100644
--- a/manifests/client/params.pp
+++ b/manifests/client/params.pp
@@ -1,4 +1,7 @@
+# @summary mongodb client params
+#
# @api private
+#
class mongodb::client::params inherits mongodb::globals {
$package_ensure = pick($mongodb::globals::version, 'present')
$manage_package = pick($mongodb::globals::manage_package, $mongodb::globals::manage_package_repo, false)
diff --git a/manifests/globals.pp b/manifests/globals.pp
index 593326417..ad9eebb6f 100644
--- a/manifests/globals.pp
+++ b/manifests/globals.pp
@@ -69,7 +69,7 @@
# specified.
$_repo_version = $version ? {
Undef => $facts['os']['family'] in ['RedHat', 'Linux', 'Suse'] ? {
- true => '3.6',
+ true => '4.4',
default => $version,
},
default => $version,
diff --git a/manifests/mongos.pp b/manifests/mongos.pp
index 1d2724576..de34b15b3 100644
--- a/manifests/mongos.pp
+++ b/manifests/mongos.pp
@@ -8,6 +8,8 @@
# @param service_manage
# @param service_provider
# @param service_name
+# @param service_user
+# @param service_group
# @param service_template
# @param service_enable
# @param service_ensure
@@ -31,6 +33,8 @@
Boolean $service_manage = $mongodb::mongos::params::service_manage,
Optional[String] $service_provider = $mongodb::mongos::params::service_provider,
Optional[String] $service_name = $mongodb::mongos::params::service_name,
+ String $service_user = 'mongodb',
+ String $service_group = 'mongodb',
Optional[String[1]] $service_template = $mongodb::mongos::params::service_template,
Boolean $service_enable = $mongodb::mongos::params::service_enable,
Stdlib::Ensure::Service $service_ensure = $mongodb::mongos::params::service_ensure,
diff --git a/manifests/mongos/config.pp b/manifests/mongos/config.pp
index 1824202a2..adf39161f 100644
--- a/manifests/mongos/config.pp
+++ b/manifests/mongos/config.pp
@@ -1,4 +1,6 @@
-# @summary PRIVATE CLASS: do not call directly
+# @summary Manages mongos config
+#
+# @api private
#
# @param package_ensure
# @param config
@@ -51,24 +53,4 @@
group => 'root',
mode => '0644',
}
-
- if $service_manage {
- if $facts['os']['family'] == 'RedHat' or $facts['os']['family'] == 'Suse' {
- file { '/etc/sysconfig/mongos' :
- ensure => $ensure,
- owner => 'root',
- group => 'root',
- mode => '0644',
- content => "OPTIONS=\"--quiet -f ${config}\"\n",
- }
- } elsif $facts['os']['family'] == 'Debian' {
- file { '/etc/init.d/mongos' :
- ensure => $ensure,
- content => template('mongodb/mongos/Debian/mongos.erb'),
- owner => 'root',
- group => 'root',
- mode => '0755',
- }
- }
- }
}
diff --git a/manifests/mongos/install.pp b/manifests/mongos/install.pp
index 1cf8de4f2..6ef4ffe1d 100644
--- a/manifests/mongos/install.pp
+++ b/manifests/mongos/install.pp
@@ -1,4 +1,6 @@
-# @summary PRIVATE CLASS: do not call directly
+# @summary Manages the mongos package
+#
+# @api private
#
# @param package_ensure
# @param package_name
diff --git a/manifests/mongos/params.pp b/manifests/mongos/params.pp
index 7be61d997..078825344 100644
--- a/manifests/mongos/params.pp
+++ b/manifests/mongos/params.pp
@@ -1,4 +1,7 @@
-# PRIVATE CLASS: do not use directly
+# @summary mongos params
+#
+# @api private
+#
class mongodb::mongos::params inherits mongodb::globals {
$manage_package = pick($mongodb::globals::manage_package, $mongodb::globals::manage_package_repo, false)
@@ -28,37 +31,10 @@
$service_ensure = 'running'
$service_status = undef
- # Amazon Linux's OS Family is 'Linux', operating system 'Amazon'.
- case $facts['os']['family'] {
- 'RedHat', 'Linux', 'Suse': {
- if $manage_package {
- $config = '/etc/mongodb-shard.conf'
- $pidfilepath = undef
- $unixsocketprefix = undef
- $logpath = undef
- $fork = undef
- $service_template = undef
- } else {
- # RedHat/CentOS doesn't come with a prepacked mongodb
- # so we assume that you are using EPEL repository.
- $config = '/etc/mongos.conf'
- $pidfilepath = '/var/run/mongodb/mongos.pid'
- $unixsocketprefix = '/var/run/mongodb'
- $logpath = '/var/log/mongodb/mongos.log'
- $fork = true
- $service_template = 'mongodb/mongos/RedHat/mongos.service-dropin.epp'
- }
- }
- 'Debian': {
- $config = '/etc/mongodb-shard.conf'
- $pidfilepath = undef
- $unixsocketprefix = undef
- $logpath = undef
- $fork = undef
- $service_template = undef
- }
- default: {
- fail("Osfamily ${facts['os']['family']} is not supported")
- }
- }
+ $config = '/etc/mongos.conf'
+ $pidfilepath = '/var/run/mongodb/mongos.pid'
+ $unixsocketprefix = '/var/run/mongodb'
+ $logpath = '/var/log/mongodb/mongos.log'
+ $fork = true
+ $service_template = 'mongodb/mongos/mongos.service-dropin.epp'
}
diff --git a/manifests/mongos/service.pp b/manifests/mongos/service.pp
index 99d80e548..d690db4a7 100644
--- a/manifests/mongos/service.pp
+++ b/manifests/mongos/service.pp
@@ -1,4 +1,6 @@
-# @summary PRIVATE CLASS: do not call directly
+# @summary Manages the mongos service
+#
+# @api private
#
# @param package_ensure
# @param service_manage
@@ -15,6 +17,8 @@
$package_ensure = $mongodb::mongos::package_ensure,
$service_manage = $mongodb::mongos::service_manage,
$service_name = $mongodb::mongos::service_name,
+ $service_user = $mongodb::mongos::service_user,
+ $service_group = $mongodb::mongos::service_group,
$service_enable = $mongodb::mongos::service_enable,
$service_ensure = $mongodb::mongos::service_ensure,
$service_status = $mongodb::mongos::service_status,
@@ -38,12 +42,10 @@
}
if $service_manage {
- if $facts['os']['family'] == 'RedHat' {
- systemd::unit_file { 'mongos.service':
- content => epp($service_template),
- enable => $real_service_enable,
- } ~> Service['mongos']
- }
+ systemd::unit_file { 'mongos.service':
+ content => epp($service_template, { service_user => $service_user, service_group => $service_user }),
+ enable => $real_service_enable,
+ } ~> Service['mongos']
service { 'mongos':
ensure => $real_service_ensure,
diff --git a/manifests/params.pp b/manifests/params.pp
index f71e512d5..90aab163f 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,4 +1,7 @@
-# PRIVATE CLASS: do not use directly
+# @summary mongodb params
+#
+# @api private
+#
class mongodb::params inherits mongodb::globals {
$ensure = true
$dbpath = '/var/lib/mongodb'
diff --git a/manifests/repo.pp b/manifests/repo.pp
index 4479235c8..82deb5ff1 100644
--- a/manifests/repo.pp
+++ b/manifests/repo.pp
@@ -1,4 +1,6 @@
-# PRIVATE CLASS: do not use directly
+# @summary Manages the mongodb repository
+#
+# @api private
#
# @param ensure
# @param version
diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp
index ff567c9f1..7ef978a8c 100644
--- a/manifests/repo/apt.pp
+++ b/manifests/repo/apt.pp
@@ -1,4 +1,6 @@
-# PRIVATE CLASS: do not use directly
+# @summary This is a repo class for apt
+#
+# @api private
class mongodb::repo::apt inherits mongodb::repo {
# we try to follow/reproduce the instruction
# from http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp
index 876146684..e5e55af17 100644
--- a/manifests/repo/yum.pp
+++ b/manifests/repo/yum.pp
@@ -1,4 +1,6 @@
-# PRIVATE CLASS: do not use directly
+# @summary This is a repo class for yum
+#
+# @api private
class mongodb::repo::yum inherits mongodb::repo {
# We try to follow/reproduce the instruction
# http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/
diff --git a/manifests/server/config.pp b/manifests/server/config.pp
index 4514fbc4c..df42494e4 100644
--- a/manifests/server/config.pp
+++ b/manifests/server/config.pp
@@ -1,4 +1,7 @@
-# PRIVATE CLASS: do not call directly
+# @summary Manages mongod config
+#
+# @api private
+#
class mongodb::server::config {
$ensure = $mongodb::server::ensure
$user = $mongodb::server::user
diff --git a/manifests/server/install.pp b/manifests/server/install.pp
index b40502ada..a20db0016 100644
--- a/manifests/server/install.pp
+++ b/manifests/server/install.pp
@@ -1,4 +1,7 @@
-# PRIVATE CLASS: do not call directly
+# @summary Manages the mongod package
+#
+# @api private
+#
class mongodb::server::install {
$package_ensure = $mongodb::server::package_ensure
$package_name = $mongodb::server::package_name
diff --git a/manifests/server/service.pp b/manifests/server/service.pp
index 001a66c44..042d9a65e 100644
--- a/manifests/server/service.pp
+++ b/manifests/server/service.pp
@@ -1,4 +1,7 @@
-# PRIVATE CLASS: do not call directly
+# @summary Manages the mongos service
+#
+# @api private
+#
class mongodb::server::service {
$ensure = $mongodb::server::service_ensure
$service_manage = $mongodb::server::service_manage
diff --git a/spec/acceptance/mongos_spec.rb b/spec/acceptance/mongos_spec.rb
index eefcafd83..da63725c5 100644
--- a/spec/acceptance/mongos_spec.rb
+++ b/spec/acceptance/mongos_spec.rb
@@ -3,18 +3,17 @@
require 'spec_helper_acceptance'
describe 'mongodb::mongos class' do
- case fact('osfamily')
- when 'Debian'
- package_name = if fact('os.distro.codename') =~ %r{^(buster|bullseye)$}
+ package_name = case fact('osfamily')
+ when 'Debian'
+ if fact('os.distro.codename') =~ %r{^(buster|bullseye)$}
'mongodb-org-server'
else
'mongodb-server'
end
- config_file = '/etc/mongodb-shard.conf'
- else
- package_name = 'mongodb-org-server'
- config_file = '/etc/mongos.conf'
- end
+ else
+ 'mongodb-org-server'
+ end
+ config_file = '/etc/mongos.conf'
describe 'installation' do
it 'works with no errors' do
diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb
index b97a517d6..6ec661c1e 100644
--- a/spec/classes/client_spec.rb
+++ b/spec/classes/client_spec.rb
@@ -11,7 +11,7 @@
it { is_expected.to compile.with_all_deps }
if facts[:os]['release']['major'] =~ %r{(10)}
- it { is_expected.to create_package('mongodb_client').with_ensure('4.4.8') }
+ it { is_expected.to create_package('mongodb_client').with_ensure('4.4.29') }
else
it { is_expected.to create_package('mongodb_client').with_ensure('present') }
end
@@ -25,7 +25,7 @@
it { is_expected.to compile.with_all_deps }
if facts[:os]['release']['major'] =~ %r{(10)}
- it { is_expected.to create_package('mongodb_client').with_ensure('4.4.8').with_name('mongodb-org-shell').with_tag('mongodb_package') }
+ it { is_expected.to create_package('mongodb_client').with_ensure('4.4.29').with_name('mongodb-org-shell').with_tag('mongodb_package') }
else
it { is_expected.to create_package('mongodb_client').with_ensure('present').with_name('mongodb-org-shell').with_tag('mongodb_package') }
end
diff --git a/spec/classes/mongos_spec.rb b/spec/classes/mongos_spec.rb
index bbccc8c85..3ebbf99f9 100644
--- a/spec/classes/mongos_spec.rb
+++ b/spec/classes/mongos_spec.rb
@@ -7,18 +7,17 @@
context "on #{os}" do
let(:facts) { facts }
- case facts[:os]['family']
- when 'Debian'
- package_name = if facts[:os]['release']['major'] =~ %r{(10)}
+ package_name = case facts[:os]['family']
+ when 'Debian'
+ if facts[:os]['release']['major'] =~ %r{(10)}
'mongodb-org-mongos'
else
'mongodb-server'
end
- config_file = '/etc/mongodb-shard.conf'
- else
- package_name = 'mongodb-org-mongos'
- config_file = '/etc/mongos.conf'
- end
+ else
+ 'mongodb-org-mongos'
+ end
+ config_file = '/etc/mongos.conf'
context 'with defaults' do
it { is_expected.to compile.with_all_deps }
@@ -27,7 +26,7 @@
it { is_expected.to contain_class('mongodb::mongos::install') }
if facts[:os]['release']['major'] =~ %r{(10)}
- it { is_expected.to contain_package('mongodb_mongos').with_ensure('4.4.8').with_name(package_name).with_tag('mongodb_package') }
+ it { is_expected.to contain_package('mongodb_mongos').with_ensure('4.4.29').with_name(package_name).with_tag('mongodb_package') }
else
it { is_expected.to contain_package('mongodb_mongos').with_ensure('present').with_name(package_name).with_tag('mongodb_package') }
end
@@ -35,40 +34,17 @@
# config
it { is_expected.to contain_class('mongodb::mongos::config') }
- case facts[:osfamily]
- when 'RedHat', 'Suse'
- expected_content = <<~CONFIG
- configdb = 127.0.0.1:27019
- fork = true
- pidfilepath = /var/run/mongodb/mongos.pid
- logpath = /var/log/mongodb/mongos.log
- unixSocketPrefix = /var/run/mongodb
- CONFIG
-
- it { is_expected.to contain_file('/etc/mongos.conf').with_content(expected_content) }
- when 'Debian'
- expected_content = <<~CONFIG
- configdb = 127.0.0.1:27019
- CONFIG
-
- it { is_expected.to contain_file('/etc/mongodb-shard.conf').with_content(expected_content) }
- end
+ expected_content = <<~CONFIG
+ configdb = 127.0.0.1:27019
+ fork = true
+ pidfilepath = /var/run/mongodb/mongos.pid
+ logpath = /var/log/mongodb/mongos.log
+ unixSocketPrefix = /var/run/mongodb
+ CONFIG
+ it { is_expected.to contain_file(config_file).with_content(expected_content) }
# service
it { is_expected.to contain_class('mongodb::mongos::service') }
-
- if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse'
- it { is_expected.to contain_file('/etc/sysconfig/mongos') }
- else
- it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
- end
-
- if facts[:osfamily] == 'Debian'
- it { is_expected.to contain_file('/etc/init.d/mongos') }
- else
- it { is_expected.not_to contain_file('/etc/init.d/mongos') }
- end
-
it { is_expected.to contain_service('mongos') }
end
@@ -92,7 +68,7 @@
it { is_expected.to compile.with_all_deps }
if facts[:os]['release']['major'] =~ %r{(10)}
- it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('4.4.8').with_tag('mongodb_package') }
+ it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('4.4.29').with_tag('mongodb_package') }
else
it { is_expected.to contain_package('mongodb_mongos').with_name('mongo-foo').with_ensure('present').with_tag('mongodb_package') }
end
@@ -106,8 +82,6 @@
end
it { is_expected.to compile.with_all_deps }
- it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
- it { is_expected.not_to contain_file('/etc/init.d/mongos') }
it { is_expected.not_to contain_service('mongos') }
end
@@ -131,29 +105,10 @@
# config
it { is_expected.to contain_class('mongodb::mongos::config') }
-
- case facts[:osfamily]
- when 'RedHat', 'Suse'
- it { is_expected.to contain_file('/etc/mongos.conf').with_ensure('absent') }
- when 'Debian'
- it { is_expected.to contain_file('/etc/mongodb-shard.conf').with_ensure('absent') }
- end
-
- if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'Suse'
- it { is_expected.to contain_file('/etc/sysconfig/mongos').with_ensure('absent') }
- else
- it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
- end
-
- if facts[:osfamily] == 'Debian'
- it { is_expected.to contain_file('/etc/init.d/mongos').with_ensure('absent') }
- else
- it { is_expected.not_to contain_file('/etc/init.d/mongos') }
- end
+ it { is_expected.to contain_file(config_file).with_ensure('absent') }
# service
it { is_expected.to contain_class('mongodb::mongos::service') }
-
it { is_expected.to contain_service('mongos').with_ensure('stopped').with_enable(false) }
end
end
diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb
index 2d8451b41..0836ccdda 100644
--- a/spec/classes/server_spec.rb
+++ b/spec/classes/server_spec.rb
@@ -49,7 +49,7 @@
if facts[:os]['family'] == 'RedHat' || facts[:os]['family'] == 'Suse'
it { is_expected.to contain_package('mongodb_server').with_ensure('present').with_name('mongodb-org-server').with_tag('mongodb_package') }
elsif facts[:os]['release']['major'] =~ %r{(10)}
- it { is_expected.to contain_package('mongodb_server').with_ensure('4.4.8').with_name('mongodb-org-server').with_tag('mongodb_package') }
+ it { is_expected.to contain_package('mongodb_server').with_ensure('4.4.29').with_name('mongodb-org-server').with_tag('mongodb_package') }
else
it { is_expected.to contain_package('mongodb_server').with_ensure('present').with_name('mongodb-server').with_tag('mongodb_package') }
end
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 7acf63019..87b5c2ccf 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -2,6 +2,4 @@
require 'voxpupuli/acceptance/spec_helper_acceptance'
-configure_beaker do |host|
- install_package(host, 'epel-release') if fact_on(host, 'os.name') == 'CentOS'
-end
+configure_beaker(modules: :metadata)
diff --git a/templates/mongos/Debian/mongos.erb b/templates/mongos/Debian/mongos.erb
deleted file mode 100644
index 98dada202..000000000
--- a/templates/mongos/Debian/mongos.erb
+++ /dev/null
@@ -1,266 +0,0 @@
-#!/bin/sh
-#
-# init.d script with LSB support.
-#
-# Copyright (c) 2007 Javier Fernandez-Sanguino
-#
-# This is free software; you may redistribute it and/or modify
-# it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2,
-# or (at your option) any later version.
-#
-# This is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License with
-# the Debian operating system, in /usr/share/common-licenses/GPL; if
-# not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-#
-### BEGIN INIT INFO
-# Provides: mongos
-# Required-Start: $network $local_fs $remote_fs
-# Required-Stop: $network $local_fs $remote_fs
-# Should-Start: $named
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: An object/document-oriented database
-# Description: MongoDB is a high-performance, open source, schema-free
-# document-oriented data store that's easy to deploy, manage
-# and use. It's network accessible, written in C++ and offers
-# the following features:
-#
-# * Collection oriented storage - easy storage of object-
-# style data
-# * Full index support, including on inner objects
-# * Query profiling
-# * Replication and fail-over support
-# * Efficient storage of binary data including large
-# objects (e.g. videos)
-# * Automatic partitioning for cloud-level scalability
-#
-# High performance, scalability, and reasonable depth of
-# functionality are the goals for the project.
-### END INIT INFO
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/bin/mongos
-DESC=database
-
-NAME=mongos
-# Defaults. Can be overridden by the /etc/default/$NAME
-# Other configuration options are located in $CONF file. See here for more:
-# http://dochub.mongodb.org/core/configurationoptions
-CONF=/etc/mongodb-shard.conf
-PIDFILE=/var/run/$NAME.pid
-ENABLE_MONGOD=yes
-
-# Include mongodb defaults if available
-if [ -f /etc/default/$NAME ] ; then
- . /etc/default/$NAME
-fi
-
-# Handle NUMA access to CPUs (SERVER-3574)
-# This verifies the existence of numactl as well as testing that the command works
-NUMACTL_ARGS="--interleave=all"
-if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
-then
- NUMACTL="`which numactl` -- $NUMACTL_ARGS"
- DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
-else
- NUMACTL=""
- DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
-fi
-
-if test ! -x $DAEMON; then
- echo "Could not find $DAEMON"
- exit 0
-fi
-
-if test "x$ENABLE_MONGOD" != "xyes"; then
- exit 0
-fi
-
-. /lib/lsb/init-functions
-
-STARTTIME=1
-DIETIME=10 # Time to wait for the server to die, in seconds
- # If this value is set too low you might not
- # let some servers to die gracefully and
- # 'restart' will not work
-
-DAEMONUSER=${DAEMONUSER:-mongodb}
-
-set -e
-
-running_pid() {
-# Check if a given process pid's cmdline matches a given name
- pid=$1
- name=$2
- [ -z "$pid" ] && return 1
- [ ! -d /proc/$pid ] && return 1
- cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
- # Is this the expected server
- [ "$cmd" != "$name" ] && return 1
- return 0
-}
-
-running() {
-# Check if the process is running looking at /proc
-# (works for all users)
-
- # No pidfile, probably no daemon present
- [ ! -f "$PIDFILE" ] && return 1
- pid=`cat $PIDFILE`
- running_pid $pid $DAEMON || return 1
- return 0
-}
-
-start_server() {
- # Recommended ulimit values for mongod or mongos
- # See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
- #
- ulimit -f unlimited
- ulimit -t unlimited
- ulimit -v unlimited
- ulimit -n 64000
- ulimit -m unlimited
-
- # In dash, ulimit takes -p for maximum user processes
- # In bash, it's -u
- if readlink /proc/$$/exe | grep -q dash
- then
- ulimit -p 32000
- else
- ulimit -u 32000
- fi
-
- # Start the process using the wrapper
- start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
- --make-pidfile --chuid $DAEMONUSER \
- --exec $NUMACTL $DAEMON $DAEMON_OPTS
- errcode=$?
- return $errcode
-}
-
-stop_server() {
-# Stop the process using the wrapper
- start-stop-daemon --stop --quiet --pidfile $PIDFILE \
- --retry 300 \
- --user $DAEMONUSER \
- --exec $DAEMON
- errcode=$?
- return $errcode
-}
-
-force_stop() {
-# Force the process to die killing it manually
- [ ! -e "$PIDFILE" ] && return
- if running ; then
- kill -15 $pid
- # Is it really dead?
- sleep "$DIETIME"s
- if running ; then
- kill -9 $pid
- sleep "$DIETIME"s
- if running ; then
- echo "Cannot kill $NAME (pid=$pid)!"
- exit 1
- fi
- fi
- fi
- rm -f $PIDFILE
-}
-
-
-case "$1" in
- start)
- log_daemon_msg "Starting $DESC" "$NAME"
- # Check if it's running first
- if running ; then
- log_progress_msg "apparently already running"
- log_end_msg 0
- exit 0
- fi
- if start_server ; then
- # NOTE: Some servers might die some time after they start,
- # this code will detect this issue if STARTTIME is set
- # to a reasonable value
- [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
- if running ; then
- # It's ok, the server started and is running
- log_end_msg 0
- else
- # It is not running after we did start
- log_end_msg 1
- fi
- else
- # Either we could not start it
- log_end_msg 1
- fi
- ;;
- stop)
- log_daemon_msg "Stopping $DESC" "$NAME"
- if running ; then
- # Only stop the server if we see it running
- errcode=0
- stop_server || errcode=$?
- log_end_msg $errcode
- else
- # If it's not running don't do anything
- log_progress_msg "apparently not running"
- log_end_msg 0
- exit 0
- fi
- ;;
- force-stop)
- # First try to stop gracefully the program
- $0 stop
- if running; then
- # If it's still running try to kill it more forcefully
- log_daemon_msg "Stopping (force) $DESC" "$NAME"
- errcode=0
- force_stop || errcode=$?
- log_end_msg $errcode
- fi
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- errcode=0
- stop_server || errcode=$?
- # Wait some sensible amount, some server need this
- [ -n "$DIETIME" ] && sleep $DIETIME
- start_server || errcode=$?
- [ -n "$STARTTIME" ] && sleep $STARTTIME
- running || errcode=$?
- log_end_msg $errcode
- ;;
- status)
-
- log_daemon_msg "Checking status of $DESC" "$NAME"
- if running ; then
- log_progress_msg "running"
- log_end_msg 0
- else
- log_progress_msg "apparently not running"
- log_end_msg 1
- exit 1
- fi
- ;;
- # MongoDB can't reload its configuration.
- reload)
- log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
- log_warning_msg "cannot re-read the config file (use restart)."
- ;;
-
- *)
- N=/etc/init.d/$NAME
- echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/templates/mongos/RedHat/mongos.service-dropin.epp b/templates/mongos/mongos.service-dropin.epp
similarity index 74%
rename from templates/mongos/RedHat/mongos.service-dropin.epp
rename to templates/mongos/mongos.service-dropin.epp
index a0f3d1b56..7a5e63eca 100644
--- a/templates/mongos/RedHat/mongos.service-dropin.epp
+++ b/templates/mongos/mongos.service-dropin.epp
@@ -1,3 +1,7 @@
+<%- | String $service_user,
+ String $service_group,
+| -%>
+
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=MongoDB Database Server
@@ -5,16 +9,11 @@ Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
-User=mongod
-Group=mongod
+User=<%= $service_user %>
+Group=<%= $service_group %>
Environment="OPTIONS=-f /etc/mongos.conf"
TimeoutStartSec=400
ExecStart=/usr/bin/mongos $OPTIONS
-ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
-ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
-ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
-PermissionsStartOnly=true
-PIDFile=/var/run/mongodb/mongos.pid
Type=forking
# file size
LimitFSIZE=infinity