Skip to content

Commit

Permalink
Merge pull request #347 from mwhahaha/idempotency-issues
Browse files Browse the repository at this point in the history
Set dbpath_fix to false by default
  • Loading branch information
wyardley authored Oct 20, 2017
2 parents d970680 + 65197d9 commit 9e2cf80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ for your OS distro.
Set this value to designate a directory for the mongod instance to store
it's data. If not specified, the module will use the default for your OS distro.

##### `dbpath_fix`
Set this value to true if you want puppet to recursively manage the permissions
of the files in the dbpath directory. If you are using the default dbpath, this
should probably be false. Set this to true if you are using a custom dbpath. The
default is false.

##### `pidfilepath`
Specify a file location to hold the PID or process ID of the mongod process.
If not specified, the module will use the default for your OS distro.
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$handle_creds = true
$store_creds = false
$rcfile = "${::root_home}/.mongorc.js"
$dbpath_fix = true
$dbpath_fix = false

$mongos_service_manage = pick($mongodb::globals::mongos_service_manage, true)
$mongos_service_enable = pick($mongodb::globals::mongos_service_enable, true)
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/server_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
is_expected.to contain_file('/etc/mongod.conf').with_content(%r{^fork=true})

is_expected.to contain_file('/root/.mongorc.js').with(ensure: 'absent')
is_expected.to_not contain_exec('fix dbpath permissions')
}
end

Expand Down Expand Up @@ -149,4 +150,17 @@

it { is_expected.to contain_file('/var/run/mongodb/mongod.pid').with_mode('0640') }
end

describe 'with dbpath_fix enabled' do
let(:pre_condition) { "class { 'mongodb::server': config => '/etc/mongod.conf', dbpath => '/var/lib/mongo', rcfile => '/root/.mongorc.js', dbpath_fix => true, user => 'foo', group => 'bar' }" }

it {
is_expected.to contain_exec('fix dbpath permissions').with(
:command => 'chown -R foo:bar /var/lib/mongo',
:path => ['/usr/bin', '/bin'],
:onlyif => "find /var/lib/mongo -not -user foo -o -not -group bar -print -quit | grep -q '.*'")
is_expected.to contain_exec('fix dbpath permissions').that_subscribes_to('File[/var/lib/mongo]')
}
end

end

0 comments on commit 9e2cf80

Please sign in to comment.