2016-09-08 15:37:09 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
module Inspec::Resources
|
|
|
|
# this resource returns additional system informatio
|
|
|
|
class System < Inspec.resource(1)
|
|
|
|
name 'sys_info'
|
|
|
|
|
|
|
|
desc 'Use the user InSpec system resource to test for operating system properties.'
|
|
|
|
example "
|
|
|
|
describe sysinfo do
|
|
|
|
its('hostname') { should eq 'example.com' }
|
|
|
|
end
|
|
|
|
"
|
|
|
|
|
2016-09-09 08:30:41 +00:00
|
|
|
# returns the hostname of the local system
|
2016-09-08 15:37:09 +00:00
|
|
|
def hostname
|
|
|
|
os = inspec.os
|
|
|
|
if os.linux?
|
|
|
|
inspec.command('hostname').stdout.chomp
|
|
|
|
elsif os.windows?
|
|
|
|
inspec.powershell('$env:computername').stdout.chomp
|
|
|
|
else
|
2016-09-09 08:30:41 +00:00
|
|
|
skip_resource 'The `sys_info.hostname` resource is not supported on your OS yet.'
|
2016-09-08 15:37:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|