Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR#182 addon: arbiter documentation + parameter replset_arbiter for mongodb::server #433

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,19 @@ set name as an argument to this set. All hosts must have the same set name.
An array of member hosts for the replica set.
Mutually exclusive with `replset_config` param.

##### `replset_arbiter`
A string to identify an arbiter instance for the replica set.
The arbiter node must also appear in `replset_members`.
Mutually exclusive with `replset_config` param.

##### `replset_config`
A hash that is used to configure the replica set.
Mutually exclusive with `replset_members` param.

```puppet
class mongodb::server {
replset => 'rsmain',
replset_config => { 'rsmain' => { ensure => present, settings => { heartbeatTimeoutSecs => 15, getLastErrorModes => { ttmode => { dc => 1 } } }, members => [{'host'=>'host1:27017', 'tags':{ 'dc' : 'east'}}, { 'host' => 'host2:27017'}, 'host3:27017'] } }
replset_config => { 'rsmain' => { ensure => present, settings => { heartbeatTimeoutSecs => 15, getLastErrorModes => { ttmode => { dc => 1 } } }, members => [{'host'=>'host1:27017', 'tags':{ 'dc' : 'east'}}, { 'host' => 'host2:27017'}, 'host3:27017'] }, arbiter => ['host3:27017'] }

}
```
Expand Down
4 changes: 4 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
Optional[String] $replset = undef,
Optional[Hash] $replset_config = undef,
Optional[Array] $replset_members = undef,
Optional[String[1]] $replset_arbiter = undef,
Optional[Boolean] $configsvr = undef,
Optional[Boolean] $shardsvr = undef,
Optional[Boolean] $rest = undef,
Expand Down Expand Up @@ -115,6 +116,8 @@
# Check that we've got either a members array or a replset_config hash
if $replset_members and $replset_config {
fail('You can provide either replset_members or replset_config, not both.')
} elsif $replset_arbiter and $replset_config {
fail('You can use replset_arbiter only with replset_members not when using replset_config.')
} elsif !$replset_members and !$replset_config {
# No members or config provided. Warn about it.
warning('Replset specified, but no replset_members or replset_config provided.')
Expand All @@ -129,6 +132,7 @@
"${replset}" => {
'ensure' => 'present',
'members' => $replset_members,
'arbiter' => $replset_arbiter,
},
}
}
Expand Down
36 changes: 34 additions & 2 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,38 @@
'mongo1:27017',
'mongo2:27017',
'mongo3:27017'
]
],
'arbiter' => :undef
}
}
end

let(:params) do
{
replset: 'rsTest',
replset_members: [
'mongo1:27017',
'mongo2:27017',
'mongo3:27017'
],
'replset_arbiter' => :undef
}
end

it { is_expected.to contain_class('mongodb::replset').with_sets(rsConf) }
end

describe 'should setup using replset_members with replset_arbiter' do
let(:rsConf) do
{
'rsTest' => {
'ensure' => 'present',
'members' => [
'mongo1:27017',
'mongo2:27017',
'mongo3:27017'
],
'arbiter' => 'mongo3:27017'
}
}
end
Expand All @@ -375,7 +406,8 @@
'mongo1:27017',
'mongo2:27017',
'mongo3:27017'
]
],
'replset_arbiter' => 'mongo3:27017'
}
end

Expand Down