Method: Inspec::Resources::System#hostname

Defined in:
lib/resources/sys_info.rb

#hostnameObject

returns the hostname of the local system



15
16
17
18
19
20
21
22
23
24
# File 'lib/resources/sys_info.rb', line 15

def hostname
  os = inspec.os
  if os.linux?
    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