Skip to content

Commit

Permalink
Refactor mongos handling
Browse files Browse the repository at this point in the history
* Use the system init script for mongos provided in EPEL
* Use the correct mongos config file
  • Loading branch information
ekohl committed Oct 20, 2018
1 parent 4e31042 commit 5e96da9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 129 deletions.
25 changes: 21 additions & 4 deletions manifests/mongos/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
$config_template = $mongodb::mongos::config_template,
$configdb = $mongodb::mongos::configdb,
$config_data = $mongodb::mongos::config_data,
$service_manage = $mongodb::mongos::service_manage,
) {

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

#Pick which config content to use
if $config_content {
$config_content_real = $config_content
} elsif $config_template {
# Template has $config_data hash available
$config_content_real = template($config_template)
} else {
# Template has $config_data hash available
$config_content_real = template('mongodb/mongodb-shard.conf.erb')
$config_content_real = template(pick($config_template, 'mongodb/mongodb-shard.conf.erb'))
}

file { $config:
Expand All @@ -28,6 +26,25 @@
mode => '0644',
}

if $service_manage {
if $facts['os']['family'] == 'RedHat' {
file { '/etc/sysconfig/mongos' :
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => "OPTIONS=\"--quiet -f ${config}\"\n",
}
} elsif $facts['os']['family'] == 'Debian' {
file { '/etc/init.d/mongos' :
ensure => file,
content => template('mongodb/mongos/Debian/mongos.erb'),
owner => 'root',
group => 'root',
mode => '0755',
}
}
}
}

}
18 changes: 0 additions & 18 deletions manifests/mongos/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@
}

if $service_manage {
if $::osfamily == 'RedHat' {
file { '/etc/sysconfig/mongos' :
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
content => 'OPTIONS="--quiet -f /etc/mongodb-shard.conf"',
before => Service['mongos'],
}
}
file { '/etc/init.d/mongos' :
ensure => file,
content => template("mongodb/mongos/${::osfamily}/mongos.erb"),
owner => 'root',
group => 'root',
mode => '0755',
before => Service['mongos'],
}
service { 'mongos':
ensure => $service_ensure_real,
name => $service_name,
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mongos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
it { is_expected.not_to contain_file('/etc/sysconfig/mongos') }
end

if %w[RedHat Debian].include?(facts[:osfamily])
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') }
Expand Down
106 changes: 0 additions & 106 deletions templates/mongos/RedHat/mongos.erb

This file was deleted.

0 comments on commit 5e96da9

Please sign in to comment.