Sha256: 17b49b60fd2ea2d30699fb43812677f17cbbfb68cf9b45162383a46d39abae0b

Contents?: true

Size: 823 Bytes

Versions: 5

Compression:

Stored size: 823 Bytes

Contents

# 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/resources/sys_info.rb
inspec-2.1.21 lib/resources/sys_info.rb
inspec-2.1.10 lib/resources/sys_info.rb
inspec-2.0.32 lib/resources/sys_info.rb
inspec-2.0.17 lib/resources/sys_info.rb