Use the bash Chef InSpec audit resource to test an arbitrary command that is run on the system using a Bash script.
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.
A command resource block declares a command to be run, one (or more) expected outputs, and the location to which that output is sent:
describe bash('command') do
it { should exist }
its('property') { should eq 'expected value' }
end
where
'command' must specify a command to be run'property' is one of exit_status, stderr, or stdout
'expected value' tests the output of the command run on the system versus the expected output stated in the testFor example:
describe bash('ls -al /') do
its('stdout') { should match /bin/ }
its('stderr') { should eq '' }
its('exit_status') { should eq 0 }
end
The exit_status property returns the exit status for the command.
its('exit_status') { should eq 0 }
The stderr property returns results of the command as returned in standard error (stderr).
its('stderr') { should eq '' }
The stdout property returns the results of the command as returned in standard output (stdout).
its('stdout') { should match /bin/ }
For a full list of available matchers, please visit our matchers page.
If an absolute path is provided, the exist matcher tests if the command exists on the filesystem at the specified location. Otherwise, the exist matcher tests if the command is found in the PATH.
it { should exist }
© 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/bash/