Skip to content

Commit

Permalink
Change set_parameter to be either as a string or an array
Browse files Browse the repository at this point in the history
  • Loading branch information
ZloeSabo committed Oct 7, 2020
1 parent 8890326 commit cec8591
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 83 deletions.
158 changes: 79 additions & 79 deletions manifests/server.pp
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
# This installs a MongoDB server. See README.md for more details.
class mongodb::server (
Variant[Boolean, String] $ensure = $mongodb::params::ensure,
String $user = $mongodb::params::user,
String $group = $mongodb::params::group,
Stdlib::Absolutepath $config = $mongodb::params::config,
Stdlib::Absolutepath $dbpath = $mongodb::params::dbpath,
Boolean $dbpath_fix = $mongodb::params::dbpath_fix,
Optional[Stdlib::Absolutepath] $pidfilepath = $mongodb::params::pidfilepath,
String $pidfilemode = $mongodb::params::pidfilemode,
Boolean $manage_pidfile = $mongodb::params::manage_pidfile,
String $rcfile = $mongodb::params::rcfile,
Boolean $service_manage = $mongodb::params::service_manage,
Optional[String] $service_provider = $mongodb::params::service_provider,
Optional[String] $service_name = $mongodb::params::service_name,
Boolean $service_enable = $mongodb::params::service_enable,
Enum['stopped', 'running'] $service_ensure = $mongodb::params::service_ensure,
Optional[Enum['stopped', 'running']] $service_status = $mongodb::params::service_status,
Variant[Boolean, String] $package_ensure = $mongodb::params::package_ensure,
String $package_name = $mongodb::params::server_package_name,
Variant[Boolean, Stdlib::Absolutepath] $logpath = $mongodb::params::logpath,
Array[Stdlib::Compat::Ip_address] $bind_ip = $mongodb::params::bind_ip,
Optional[Boolean] $ipv6 = undef,
Boolean $logappend = true,
Optional[String] $system_logrotate = undef,
Optional[Boolean] $fork = $mongodb::params::fork,
Optional[Integer[1, 65535]] $port = undef,
Optional[Boolean] $journal = $mongodb::params::journal,
Optional[Boolean] $nojournal = undef,
Optional[Boolean] $smallfiles = undef,
Optional[Boolean] $cpu = undef,
Boolean $auth = false,
Optional[Boolean] $noauth = undef,
Optional[Boolean] $verbose = undef,
Optional[String] $verbositylevel = undef,
Optional[Boolean] $objcheck = undef,
Optional[Boolean] $quota = undef,
Optional[Integer] $quotafiles = undef,
Optional[Integer[0, 7]] $diaglog = undef,
Optional[Boolean] $directoryperdb = undef,
$profile = undef,
Optional[Integer] $maxconns = undef,
Optional[Integer] $oplog_size = undef,
$nohints = undef,
Optional[Boolean] $nohttpinterface = undef,
Optional[Boolean] $noscripting = undef,
Optional[Boolean] $notablescan = undef,
Optional[Boolean] $noprealloc = undef,
Optional[Integer] $nssize = undef,
$mms_token = undef,
$mms_name = undef,
$mms_interval = undef,
Optional[String] $replset = undef,
Optional[Hash] $replset_config = undef,
Optional[Array] $replset_members = undef,
Optional[Boolean] $configsvr = undef,
Optional[Boolean] $shardsvr = undef,
Optional[Boolean] $rest = undef,
Optional[Boolean] $quiet = undef,
Optional[Integer] $slowms = undef,
Optional[Stdlib::Absolutepath] $keyfile = undef,
Optional[String[6]] $key = undef,
Optional[String] $set_parameter = undef,
Optional[Boolean] $syslog = undef,
$config_content = undef,
Optional[String] $config_template = undef,
Optional[Hash] $config_data = undef,
Optional[Boolean] $ssl = undef,
Optional[Stdlib::Absolutepath] $ssl_key = undef,
Optional[Stdlib::Absolutepath] $ssl_ca = undef,
Boolean $ssl_weak_cert = false,
Boolean $ssl_invalid_hostnames = false,
Enum['requireSSL', 'preferSSL', 'allowSSL'] $ssl_mode = 'requireSSL',
Boolean $restart = $mongodb::params::restart,
Optional[String] $storage_engine = undef,
Boolean $create_admin = $mongodb::params::create_admin,
String $admin_username = $mongodb::params::admin_username,
Optional[String] $admin_password = undef,
Boolean $handle_creds = $mongodb::params::handle_creds,
Boolean $store_creds = $mongodb::params::store_creds,
Array $admin_roles = $mongodb::params::admin_roles,
Variant[Boolean, String] $ensure = $mongodb::params::ensure,
String $user = $mongodb::params::user,
String $group = $mongodb::params::group,
Stdlib::Absolutepath $config = $mongodb::params::config,
Stdlib::Absolutepath $dbpath = $mongodb::params::dbpath,
Boolean $dbpath_fix = $mongodb::params::dbpath_fix,
Optional[Stdlib::Absolutepath] $pidfilepath = $mongodb::params::pidfilepath,
String $pidfilemode = $mongodb::params::pidfilemode,
Boolean $manage_pidfile = $mongodb::params::manage_pidfile,
String $rcfile = $mongodb::params::rcfile,
Boolean $service_manage = $mongodb::params::service_manage,
Optional[String] $service_provider = $mongodb::params::service_provider,
Optional[String] $service_name = $mongodb::params::service_name,
Boolean $service_enable = $mongodb::params::service_enable,
Enum['stopped', 'running'] $service_ensure = $mongodb::params::service_ensure,
Optional[Enum['stopped', 'running']] $service_status = $mongodb::params::service_status,
Variant[Boolean, String] $package_ensure = $mongodb::params::package_ensure,
String $package_name = $mongodb::params::server_package_name,
Variant[Boolean, Stdlib::Absolutepath] $logpath = $mongodb::params::logpath,
Array[Stdlib::Compat::Ip_address] $bind_ip = $mongodb::params::bind_ip,
Optional[Boolean] $ipv6 = undef,
Boolean $logappend = true,
Optional[String] $system_logrotate = undef,
Optional[Boolean] $fork = $mongodb::params::fork,
Optional[Integer[1, 65535]] $port = undef,
Optional[Boolean] $journal = $mongodb::params::journal,
Optional[Boolean] $nojournal = undef,
Optional[Boolean] $smallfiles = undef,
Optional[Boolean] $cpu = undef,
Boolean $auth = false,
Optional[Boolean] $noauth = undef,
Optional[Boolean] $verbose = undef,
Optional[String] $verbositylevel = undef,
Optional[Boolean] $objcheck = undef,
Optional[Boolean] $quota = undef,
Optional[Integer] $quotafiles = undef,
Optional[Integer[0, 7]] $diaglog = undef,
Optional[Boolean] $directoryperdb = undef,
$profile = undef,
Optional[Integer] $maxconns = undef,
Optional[Integer] $oplog_size = undef,
$nohints = undef,
Optional[Boolean] $nohttpinterface = undef,
Optional[Boolean] $noscripting = undef,
Optional[Boolean] $notablescan = undef,
Optional[Boolean] $noprealloc = undef,
Optional[Integer] $nssize = undef,
$mms_token = undef,
$mms_name = undef,
$mms_interval = undef,
Optional[String] $replset = undef,
Optional[Hash] $replset_config = undef,
Optional[Array] $replset_members = undef,
Optional[Boolean] $configsvr = undef,
Optional[Boolean] $shardsvr = undef,
Optional[Boolean] $rest = undef,
Optional[Boolean] $quiet = undef,
Optional[Integer] $slowms = undef,
Optional[Stdlib::Absolutepath] $keyfile = undef,
Optional[String[6]] $key = undef,
Optional[Variant[String[1], Array[String[1]]]] $set_parameter = undef,
Optional[Boolean] $syslog = undef,
$config_content = undef,
Optional[String] $config_template = undef,
Optional[Hash] $config_data = undef,
Optional[Boolean] $ssl = undef,
Optional[Stdlib::Absolutepath] $ssl_key = undef,
Optional[Stdlib::Absolutepath] $ssl_ca = undef,
Boolean $ssl_weak_cert = false,
Boolean $ssl_invalid_hostnames = false,
Enum['requireSSL', 'preferSSL', 'allowSSL'] $ssl_mode = 'requireSSL',
Boolean $restart = $mongodb::params::restart,
Optional[String] $storage_engine = undef,
Boolean $create_admin = $mongodb::params::create_admin,
String $admin_username = $mongodb::params::admin_username,
Optional[String] $admin_password = undef,
Boolean $handle_creds = $mongodb::params::handle_creds,
Boolean $store_creds = $mongodb::params::store_creds,
Array $admin_roles = $mongodb::params::admin_roles,
) inherits mongodb::params {
contain mongodb::server::install
contain mongodb::server::config
Expand Down
14 changes: 12 additions & 2 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,24 @@
it { is_expected.to contain_file('/root/.mongorc.js') }
end

describe 'when specifying set_parameter value' do
describe 'when specifying set_parameter array value' do
let :params do
{
set_parameter: ['textSearchEnable=true']
}
end

it { is_expected.to contain_file(config_file).with_content(%r{^setParameter:\n textSearchEnable=true}) }
end

describe 'when specifying set_parameter string value' do
let :params do
{
set_parameter: 'textSearchEnable=true'
}
end

it { is_expected.to contain_file(config_file).with_content(%r{^setParameter: textSearchEnable=true}) }
it { is_expected.to contain_file(config_file).with_content(%r{^setParameter:\n textSearchEnable=true}) }
end

describe 'with journal:' do
Expand Down
6 changes: 4 additions & 2 deletions templates/mongodb.conf.2.6.erb
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ operationProfiling.mode: all
operationProfiling.slowOpThresholdMs: <%= @slowms %>
<% end -%>


<% if @set_parameter -%>
setParameter: <%= @set_parameter %>
setParameter:
<% [@set_parameter].flatten.each do |v| -%>
<%= v %>
<% end -%>
<% end -%>

<% if @config_data -%>
Expand Down

0 comments on commit cec8591

Please sign in to comment.