puppet-mongodb
puppet-mongodb copied to clipboard
dbpath_fix find command issue
Affected Puppet, Ruby, OS and module versions/distributions
It is not puppet related
How to reproduce (e.g Puppet code you use)
set dbpath_fix to true
class { '::mongodb::server':
dbpath_fix => true,
}
What are you seeing
dbpath ownership is not properly updated. The reason is the order of switches in the command used here https://github.com/voxpupuli/puppet-mongodb/blob/master/manifests/server/config.pp#L139
onlyif => "find ${dbpath} -not -user ${user} -o -not -group ${group} -print -quit | grep -q '.*'",
above command is not working properly, consider below output
root@8e8583b9f092:/# tree -ug mongodb/
mongodb/
`-- [root root ] 1
`-- [root root ] 2
`-- [root root ] 3
3 directories, 0 files
In order to fix those permissions we need find command to return 0, but it returns 1 instead:
root@8e8583b9f092:/# find mongodb/ -not -user mongod -o -not -group mongod -print -quit | grep -q '.*'; echo $?
1
What behaviour did you expect instead
find command to return 0 whenever it should:
root@8e8583b9f092:/# tree -ug mongodb/
mongodb/
`-- [root root ] 1
`-- [root root ] 2
`-- [root root ] 3
3 directories, 0 files
root@8e8583b9f092:/# find mongodb/ -print -not -user mongod -o -not -group mongod -quit | grep -q '.*'; echo $?
0