Use the sys_info Chef InSpec audit resource to test for operating system properties for the named host, and then returns that info as standard output.
This resource is distributed along with Chef InSpec itself. You can use it automatically.
This resource first became available in v1.0.0 of InSpec.
An sys_info resource block declares the hostname to be tested:
describe sys_info do
its('hostname') { should eq 'value' }
end
The hostname property tests the host for which standard output is returned:
its('hostname') { should eq 'value' }
The fqdn property tests the ‘fully qualified domain name’ of the system:
its('fqdn') { should eq 'value' }
The domain property tests the name of the DNS domain:
its('domain') { should eq 'value' }
The ip-address property tests all network addresses of the host:
its('ip-address') { should eq 'value' }
The short property tests the host name cut at the first dot:
its('short') { should eq 'value' }
The manufacturer property tests the host for which standard output is returned:
its('manufacturer') { should eq 'ACME Corp.' }
The model property tests the host for which standard output is returned:
its('model') { should eq 'Flux Capacitor' }
The following examples show how to use this Chef InSpec audit resource.
describe sys_info do
its('hostname') { should eq 'example.com' }
end
describe file('/path/to/some/file') do
its('content') { should match sys_info.hostname }
end
Options can be passed as arguments to hostname as well.
describe file('/path/to/some/file') do
its('content') { should match sys_info.hostname('full') }
end
Currently supported arguments to hostname on Linux platforms are ‘full’|‘f’|‘fqdn’|‘long’, ‘domain’|’d', ‘ip_address’|‘i’, and ‘short’|’s'. Mac currently supports ‘full’|‘f’|‘fqdn’|‘long’ and ‘short’|’s'
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/sys_info/