mirror of
https://github.com/inspec/inspec
synced 2024-11-14 00:47:10 +00:00
7b23fa479c
* Add correct `supports platform` to resources. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Remove 'os_family' and update platforms to specify what they did. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Add esx and cisco to generic resources. Signed-off-by: Jared Quick <jquick@chef.io>
28 lines
795 B
Ruby
28 lines
795 B
Ruby
# encoding: utf-8
|
|
module Inspec::Resources
|
|
# this resource returns additional system informatio
|
|
class System < Inspec.resource(1)
|
|
name 'sys_info'
|
|
supports platform: 'unix'
|
|
supports platform: 'windows'
|
|
|
|
desc 'Use the user InSpec system resource to test for operating system properties.'
|
|
example "
|
|
describe sys_info do
|
|
its('hostname') { should eq 'example.com' }
|
|
end
|
|
"
|
|
|
|
# returns the hostname of the local system
|
|
def hostname
|
|
os = inspec.os
|
|
if os.linux? || os.darwin?
|
|
inspec.command('hostname').stdout.chomp
|
|
elsif os.windows?
|
|
inspec.powershell('$env:computername').stdout.chomp
|
|
else
|
|
skip_resource 'The `sys_info.hostname` resource is not supported on your OS yet.'
|
|
end
|
|
end
|
|
end
|
|
end
|