Skip to content

Commit 5e96da9

Browse files
committed
Refactor mongos handling
* Use the system init script for mongos provided in EPEL * Use the correct mongos config file
1 parent 4e31042 commit 5e96da9

File tree

4 files changed

+22
-129
lines changed

4 files changed

+22
-129
lines changed

manifests/mongos/config.pp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
$config_template = $mongodb::mongos::config_template,
77
$configdb = $mongodb::mongos::configdb,
88
$config_data = $mongodb::mongos::config_data,
9+
$service_manage = $mongodb::mongos::service_manage,
910
) {
1011

1112
if ($ensure == 'present' or $ensure == true) {
1213

1314
#Pick which config content to use
1415
if $config_content {
1516
$config_content_real = $config_content
16-
} elsif $config_template {
17-
# Template has $config_data hash available
18-
$config_content_real = template($config_template)
1917
} else {
2018
# Template has $config_data hash available
21-
$config_content_real = template('mongodb/mongodb-shard.conf.erb')
19+
$config_content_real = template(pick($config_template, 'mongodb/mongodb-shard.conf.erb'))
2220
}
2321

2422
file { $config:
@@ -28,6 +26,25 @@
2826
mode => '0644',
2927
}
3028

29+
if $service_manage {
30+
if $facts['os']['family'] == 'RedHat' {
31+
file { '/etc/sysconfig/mongos' :
32+
ensure => file,
33+
owner => 'root',
34+
group => 'root',
35+
mode => '0644',
36+
content => "OPTIONS=\"--quiet -f ${config}\"\n",
37+
}
38+
} elsif $facts['os']['family'] == 'Debian' {
39+
file { '/etc/init.d/mongos' :
40+
ensure => file,
41+
content => template('mongodb/mongos/Debian/mongos.erb'),
42+
owner => 'root',
43+
group => 'root',
44+
mode => '0755',
45+
}
46+
}
47+
}
3148
}
3249

3350
}

manifests/mongos/service.pp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@
2424
}
2525

2626
if $service_manage {
27-
if $::osfamily == 'RedHat' {
28-
file { '/etc/sysconfig/mongos' :
29-
ensure => file,
30-
owner => 'root',
31-
group => 'root',
32-
mode => '0755',
33-
content => 'OPTIONS="--quiet -f /etc/mongodb-shard.conf"',
34-
before => Service['mongos'],
35-
}
36-
}
37-
file { '/etc/init.d/mongos' :
38-
ensure => file,
39-
content => template("mongodb/mongos/${::osfamily}/mongos.erb"),
40-
owner => 'root',
41-
group => 'root',
42-
mode => '0755',
43-
before => Service['mongos'],
44-
}
4527
service { 'mongos':
4628
ensure => $service_ensure_real,
4729
name => $service_name,

spec/classes/mongos_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
3838
end
3939

40-
if %w[RedHat Debian].include?(facts[:osfamily])
40+
if facts[:osfamily] == 'Debian'
4141
it { is_expected.to contain_file('/etc/init.d/mongos') }
4242
else
4343
it { is_expected.not_to contain_file('/etc/init.d/mongos') }

templates/mongos/RedHat/mongos.erb

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)