Use the mongodb_conf Chef InSpec audit resource to test the contents of the configuration file for MongoDB, typically located at /etc/mongod.conf or C:\Program Files\MongoDB\Server\<version>\bin\mongod.cfg, depending on the platform.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
A mongodb_conf resource block declares one (or more) settings in the mongodb.conf file, and then compares the setting in the configuration file to the value stated in the test:
describe mongodb_conf('path') do
its('setting') { should eq 'value' }
end
where
'setting' specifies a setting in the mongodb.conf file('path') is the non-default path to the mongodb.conf file (optional)should eq 'value' is the value that is expectedThe following examples show how to use this Chef InSpec audit resource.
describe mongodb_conf do
its(["security", "enableEncryption"]) { should eq true }
end
describe mongodb_conf do
its(["net", "port"]) { should eq 27017 }
end
describe mongodb_conf do
its(["security", "authorization"]) { should eq "enabled" }
end
For a full list of available matchers, please visit our matchers page.
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/resources/mongodb_conf/