Skip to content

Commit 5ece1ea

Browse files
authored
Merge pull request #698 from StatensPensjonskasse/mongos-as-systemd-service
Mongos as systemd service
2 parents 1a33bf6 + 8f8872a commit 5ece1ea

25 files changed

+130
-795
lines changed

REFERENCE.md

Lines changed: 30 additions & 373 deletions
Large diffs are not rendered by default.

data/Debian-10.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
---
2-
mongodb::globals::version: '4.4.8' # Debian 10 doesn't provide mongodb 3.6.
2+
mongodb::globals::version: '4.4.29' # Debian 10 doesn't provide mongodb 3.6.
33
mongodb::globals::manage_package_repo: true # Debian 10 doesn't provide mongodb packages. So manage it!

data/Debian-family.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
mongodb::mongos::service_user: 'mongodb'
3+
mongodb::mongos::service_group: 'mongodb'

data/RedHat-family.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
mongodb::mongos::service_user: 'mongod'
3+
mongodb::mongos::service_group: 'mongod'

manifests/client/params.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# @summary mongodb client params
2+
#
13
# @api private
4+
#
25
class mongodb::client::params inherits mongodb::globals {
36
$package_ensure = pick($mongodb::globals::version, 'present')
47
$manage_package = pick($mongodb::globals::manage_package, $mongodb::globals::manage_package_repo, false)

manifests/globals.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# specified.
7070
$_repo_version = $version ? {
7171
Undef => $facts['os']['family'] in ['RedHat', 'Linux', 'Suse'] ? {
72-
true => '3.6',
72+
true => '4.4',
7373
default => $version,
7474
},
7575
default => $version,

manifests/mongos.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# @param service_manage
99
# @param service_provider
1010
# @param service_name
11+
# @param service_user
12+
# @param service_group
1113
# @param service_template
1214
# @param service_enable
1315
# @param service_ensure
@@ -31,6 +33,8 @@
3133
Boolean $service_manage = $mongodb::mongos::params::service_manage,
3234
Optional[String] $service_provider = $mongodb::mongos::params::service_provider,
3335
Optional[String] $service_name = $mongodb::mongos::params::service_name,
36+
String $service_user = 'mongodb',
37+
String $service_group = 'mongodb',
3438
Optional[String[1]] $service_template = $mongodb::mongos::params::service_template,
3539
Boolean $service_enable = $mongodb::mongos::params::service_enable,
3640
Stdlib::Ensure::Service $service_ensure = $mongodb::mongos::params::service_ensure,

manifests/mongos/config.pp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# @summary PRIVATE CLASS: do not call directly
1+
# @summary Manages mongos config
2+
#
3+
# @api private
24
#
35
# @param package_ensure
46
# @param config
@@ -51,24 +53,4 @@
5153
group => 'root',
5254
mode => '0644',
5355
}
54-
55-
if $service_manage {
56-
if $facts['os']['family'] == 'RedHat' or $facts['os']['family'] == 'Suse' {
57-
file { '/etc/sysconfig/mongos' :
58-
ensure => $ensure,
59-
owner => 'root',
60-
group => 'root',
61-
mode => '0644',
62-
content => "OPTIONS=\"--quiet -f ${config}\"\n",
63-
}
64-
} elsif $facts['os']['family'] == 'Debian' {
65-
file { '/etc/init.d/mongos' :
66-
ensure => $ensure,
67-
content => template('mongodb/mongos/Debian/mongos.erb'),
68-
owner => 'root',
69-
group => 'root',
70-
mode => '0755',
71-
}
72-
}
73-
}
7456
}

manifests/mongos/install.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# @summary PRIVATE CLASS: do not call directly
1+
# @summary Manages the mongos package
2+
#
3+
# @api private
24
#
35
# @param package_ensure
46
# @param package_name

manifests/mongos/params.pp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# PRIVATE CLASS: do not use directly
1+
# @summary mongos params
2+
#
3+
# @api private
4+
#
25
class mongodb::mongos::params inherits mongodb::globals {
36
$manage_package = pick($mongodb::globals::manage_package, $mongodb::globals::manage_package_repo, false)
47

@@ -28,37 +31,10 @@
2831
$service_ensure = 'running'
2932
$service_status = undef
3033

31-
# Amazon Linux's OS Family is 'Linux', operating system 'Amazon'.
32-
case $facts['os']['family'] {
33-
'RedHat', 'Linux', 'Suse': {
34-
if $manage_package {
35-
$config = '/etc/mongodb-shard.conf'
36-
$pidfilepath = undef
37-
$unixsocketprefix = undef
38-
$logpath = undef
39-
$fork = undef
40-
$service_template = undef
41-
} else {
42-
# RedHat/CentOS doesn't come with a prepacked mongodb
43-
# so we assume that you are using EPEL repository.
44-
$config = '/etc/mongos.conf'
45-
$pidfilepath = '/var/run/mongodb/mongos.pid'
46-
$unixsocketprefix = '/var/run/mongodb'
47-
$logpath = '/var/log/mongodb/mongos.log'
48-
$fork = true
49-
$service_template = 'mongodb/mongos/RedHat/mongos.service-dropin.epp'
50-
}
51-
}
52-
'Debian': {
53-
$config = '/etc/mongodb-shard.conf'
54-
$pidfilepath = undef
55-
$unixsocketprefix = undef
56-
$logpath = undef
57-
$fork = undef
58-
$service_template = undef
59-
}
60-
default: {
61-
fail("Osfamily ${facts['os']['family']} is not supported")
62-
}
63-
}
34+
$config = '/etc/mongos.conf'
35+
$pidfilepath = '/var/run/mongodb/mongos.pid'
36+
$unixsocketprefix = '/var/run/mongodb'
37+
$logpath = '/var/log/mongodb/mongos.log'
38+
$fork = true
39+
$service_template = 'mongodb/mongos/mongos.service-dropin.epp'
6440
}

0 commit comments

Comments
 (0)