Skip to content

Commit c50bdb7

Browse files
committed
Merge pull request #179 from atrepca/MODULES-1712
Add $restart param to control service restarts
2 parents 14117ae + ab566b6 commit c50bdb7

6 files changed

Lines changed: 40 additions & 13 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,13 @@ Default: <>
430430
#####`ssl_ca`
431431
Default: <>
432432

433-
434433
#####`service_manage`
435434
Whether or not the MongoDB service resource should be part of the catalog.
436435
Default: true
437436

437+
#####`restart`
438+
Specifies whether the service should be restarted on config changes. Default: 'true'
439+
438440
####Class: mongodb::mongos
439441
class. This class should only be used if you want to implement sharding within
440442
your mongodb deployment.
@@ -486,6 +488,9 @@ This setting can be used to specify if puppet should install the package or not
486488
This setting can be used to specify the name of the package that should be installed.
487489
If not specified, the module will use whatever service name is the default for your OS distro.
488490

491+
#####`restart`
492+
Specifies whether the service should be restarted on config changes. Default: 'true'
493+
489494
### Definitions
490495

491496
#### Definition: mongodb:db

manifests/mongos.pp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,25 @@
1818
$fork = $mongodb::params::mongos_fork,
1919
$bind_ip = undef,
2020
$port = undef,
21+
$restart = $mongodb::params::mongos_restart,
2122
) inherits mongodb::params {
2223

2324
if ($ensure == 'present' or $ensure == true) {
24-
anchor { 'mongodb::mongos::start': }->
25-
class { '::mongodb::mongos::install': }->
26-
class { '::mongodb::mongos::config': }->
27-
class { '::mongodb::mongos::service': }->
28-
anchor { 'mongodb::mongos::end': }
25+
if $restart {
26+
anchor { 'mongodb::mongos::start': }->
27+
class { 'mongodb::mongos::install': }->
28+
# If $restart is true, notify the service on config changes (~>)
29+
class { 'mongodb::mongos::config': }~>
30+
class { 'mongodb::mongos::service': }->
31+
anchor { 'mongodb::mongos::end': }
32+
} else {
33+
anchor { 'mongodb::mongos::start': }->
34+
class { 'mongodb::mongos::install': }->
35+
# If $restart is false, config changes won't restart the service (->)
36+
class { 'mongodb::mongos::config': }->
37+
class { 'mongodb::mongos::service': }->
38+
anchor { 'mongodb::mongos::end': }
39+
}
2940
} else {
3041
anchor { 'mongodb::mongos::start': }->
3142
class { '::mongodb::mongos::service': }->

manifests/mongos/config.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
owner => 'root',
2121
group => 'root',
2222
mode => '0644',
23-
notify => Class['mongodb::mongos::service']
2423
}
2524

2625
}

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
$service_enable = pick($mongodb::globals::service_enable, true)
88
$service_ensure = pick($mongodb::globals::service_ensure, 'running')
99
$service_status = $mongodb::globals::service_status
10+
$restart = true
1011

1112
$mongos_service_manage = pick($mongodb::globals::mongos_service_manage, true)
1213
$mongos_service_enable = pick($mongodb::globals::mongos_service_enable, true)
1314
$mongos_service_ensure = pick($mongodb::globals::mongos_service_ensure, 'running')
1415
$mongos_service_status = $mongodb::globals::mongos_service_status
1516
$mongos_configdb = '127.0.0.1:27019'
17+
$mongos_restart = true
1618

1719
# Amazon Linux's OS Family is 'Linux', operating system 'Amazon'.
1820
case $::osfamily {

manifests/server.pp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
$ssl = undef,
6565
$ssl_key = undef,
6666
$ssl_ca = undef,
67+
$restart = $mongodb::params::restart,
6768

6869
# Deprecated parameters
6970
$master = undef,
@@ -78,11 +79,21 @@
7879
}
7980

8081
if ($ensure == 'present' or $ensure == true) {
81-
anchor { 'mongodb::server::start': }->
82-
class { '::mongodb::server::install': }->
83-
class { '::mongodb::server::config': }->
84-
class { '::mongodb::server::service': }->
85-
anchor { 'mongodb::server::end': }
82+
if $restart {
83+
anchor { 'mongodb::server::start': }->
84+
class { 'mongodb::server::install': }->
85+
# If $restart is true, notify the service on config changes (~>)
86+
class { 'mongodb::server::config': }~>
87+
class { 'mongodb::server::service': }->
88+
anchor { 'mongodb::server::end': }
89+
} else {
90+
anchor { 'mongodb::server::start': }->
91+
class { 'mongodb::server::install': }->
92+
# If $restart is false, config changes won't restart the service (->)
93+
class { 'mongodb::server::config': }->
94+
class { 'mongodb::server::service': }->
95+
anchor { 'mongodb::server::end': }
96+
}
8697
} else {
8798
anchor { 'mongodb::server::start': }->
8899
class { '::mongodb::server::service': }->

manifests/server/config.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
owner => 'root',
9898
group => 'root',
9999
mode => '0644',
100-
notify => Class['mongodb::server::service']
101100
}
102101

103102
file { $dbpath:

0 commit comments

Comments
 (0)