Skip to content

Commit 15ec236

Browse files
authored
Merge pull request #420 from ekohl/replace-anchors
Replace anchors with contain
2 parents eac1c74 + a0e1ada commit 15ec236

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

manifests/mongos.pp

+8-15
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,22 @@
2222
Optional[Integer[1, 65535]] $port = undef,
2323
Boolean $restart = $mongodb::params::mongos_restart,
2424
) inherits mongodb::params {
25+
contain mongodb::mongos::install
26+
contain mongodb::mongos::config
27+
contain mongodb::mongos::service
2528

2629
if ($ensure == 'present' or $ensure == true) {
30+
Class['mongodb::mongos::install'] -> Class['mongodb::mongos::config']
31+
2732
if $restart {
28-
anchor { 'mongodb::mongos::start': }
29-
-> class { 'mongodb::mongos::install': }
3033
# If $restart is true, notify the service on config changes (~>)
31-
-> class { 'mongodb::mongos::config': }
32-
~> class { 'mongodb::mongos::service': }
33-
-> anchor { 'mongodb::mongos::end': }
34+
Class['mongodb::mongos::config'] ~> Class['mongodb::mongos::service']
3435
} else {
35-
anchor { 'mongodb::mongos::start': }
36-
-> class { 'mongodb::mongos::install': }
3736
# If $restart is false, config changes won't restart the service (->)
38-
-> class { 'mongodb::mongos::config': }
39-
-> class { 'mongodb::mongos::service': }
40-
-> anchor { 'mongodb::mongos::end': }
37+
Class['mongodb::mongos::config'] -> Class['mongodb::mongos::service']
4138
}
4239
} else {
43-
anchor { 'mongodb::mongos::start': }
44-
-> class { 'mongodb::mongos::service': }
45-
-> class { 'mongodb::mongos::config': }
46-
-> class { 'mongodb::mongos::install': }
47-
-> anchor { 'mongodb::mongos::end': }
40+
Class['mongodb::mongos::service'] -> Class['mongodb::mongos::config'] -> Class['mongodb::mongos::install']
4841
}
4942

5043
}

manifests/server.pp

+9-20
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,22 @@
8080
Array $admin_roles = $mongodb::params::admin_roles,
8181
) inherits mongodb::params {
8282

83+
contain mongodb::server::install
84+
contain mongodb::server::config
85+
contain mongodb::server::service
86+
8387
if ($ensure == 'present' or $ensure == true) {
88+
Class['mongodb::server::install'] -> Class['mongodb::server::config']
89+
8490
if $restart {
85-
anchor { 'mongodb::server::start': }
86-
-> class { 'mongodb::server::install': }
8791
# If $restart is true, notify the service on config changes (~>)
88-
-> class { 'mongodb::server::config': }
89-
~> class { 'mongodb::server::service': }
90-
-> anchor { 'mongodb::server::end': }
92+
Class['mongodb::server::config'] ~> Class['mongodb::server::service']
9193
} else {
92-
anchor { 'mongodb::server::start': }
93-
-> class { 'mongodb::server::install': }
9494
# If $restart is false, config changes won't restart the service (->)
95-
-> class { 'mongodb::server::config': }
96-
-> class { 'mongodb::server::service': }
97-
-> anchor { 'mongodb::server::end': }
95+
Class['mongodb::server::config'] -> Class['mongodb::server::service']
9896
}
9997
} else {
100-
anchor { 'mongodb::server::start': }
101-
-> class { 'mongodb::server::service': }
102-
-> class { 'mongodb::server::config': }
103-
-> class { 'mongodb::server::install': }
104-
-> anchor { 'mongodb::server::end': }
98+
Class['mongodb::server::service'] -> Class['mongodb::server::config'] -> Class['mongodb::server::install']
10599
}
106100

107101
if $create_admin and ($service_ensure == 'running' or $service_ensure == true) {
@@ -111,9 +105,6 @@
111105
roles => $admin_roles,
112106
}
113107

114-
# Make sure it runs at the correct point
115-
Anchor['mongodb::server::end'] -> Mongodb::Db['admin']
116-
117108
# Make sure it runs before other DB creation
118109
Mongodb::Db['admin'] -> Mongodb::Db <| title != 'admin' |>
119110
}
@@ -148,8 +139,6 @@
148139

149140
$replset_config_real = $_replset_config # lint:ignore:variable_is_lowercase required for compatibility
150141

151-
Anchor['mongodb::server::end'] -> Class['mongodb::replset']
152-
153142
# Make sure that the ordering is correct
154143
if $create_admin {
155144
Class['mongodb::replset'] -> Mongodb::Db['admin']

spec/classes/server_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
'roles' => %w[userAdmin readWrite dbAdmin dbAdminAnyDatabase
5050
readAnyDatabase readWriteAnyDatabase userAdminAnyDatabase
5151
clusterAdmin clusterManager clusterMonitor hostManager
52-
root restore]).that_requires('Anchor[mongodb::server::end]')
52+
root restore])
5353
}
54+
it { is_expected.to contain_mongodb_database('admin').that_requires('Service[mongodb]') }
5455
end
5556

5657
context 'when deploying on Solaris' do

0 commit comments

Comments
 (0)