Use the postfix_conf Chef InSpec audit resource to test the main configuration of the Postfix Mail Transfer Agent.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
A postfix_conf resource block declares the configuration settings to be tested:
describe postfix_conf do
its('setting_name') { should cmp 'value' }
end
where
'setting_name' is a setting key defined in main.cf{ should cmp 'value' } is the value to be expectedWhen using postfix_conf with a custom configuration directory, the following syntax can be used:
describe postfix_conf('path') do
...
end
where
'path' is the path to your Postfix configuration (ex. ‘/etc/my/postfix/path/main.cf’)This resource supports any of the settings listed in the main.cf file as properties.
The following examples show how to use this Chef InSpec audit resource.
For example, the following Postfix configuration:
/etc/postfix/main.cf:
myorigin = $myhostname
myhostname = host.local.domain
mynetworks = 127.0.0.0/8
can be tested like this:
describe postfix_conf do
its('myorigin') { should cmp '$myhostname' }
its('myhostname') { should cmp 'host.local.domain' }
its('mynetworks') { should cmp '127.0.0.0/8' }
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/postfix_conf/