mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
add sys_info resource to get information about the hostname
This commit is contained in:
parent
23410755ea
commit
82a4e21cf7
2 changed files with 27 additions and 0 deletions
|
@ -106,6 +106,7 @@ require 'resources/service'
|
|||
require 'resources/shadow'
|
||||
require 'resources/ssl'
|
||||
require 'resources/ssh_conf'
|
||||
require 'resources/sys_info'
|
||||
require 'resources/users'
|
||||
require 'resources/vbscript'
|
||||
require 'resources/windows_feature'
|
||||
|
|
26
lib/resources/sys_info.rb
Normal file
26
lib/resources/sys_info.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# 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
|
||||
"
|
||||
|
||||
def hostname
|
||||
os = inspec.os
|
||||
if os.linux?
|
||||
inspec.command('hostname').stdout.chomp
|
||||
elsif os.windows?
|
||||
# windows hostname
|
||||
inspec.powershell('$env:computername').stdout.chomp
|
||||
else
|
||||
return skip_resource 'The `system` resource is not supported on your OS yet.'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue