Method: Inspec::Resources::System#linux_hostname

Defined in:
lib/inspec/resources/sys_info.rb

#linux_hostname(opt = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/inspec/resources/sys_info.rb', line 47

def linux_hostname(opt = nil)
  if opt
    opt = case opt
          when "f", "long", "fqdn", "full"
            " -f"
          when "d", "domain"
            " -d"
          when "i", "ip_address"
            " -I"
          when "s", "short"
            " -s"
          else
            "ERROR"
          end
  end
  if opt == "ERROR"
    skip_resource "The `sys_info.hostname` resource is not supported with that option on your OS."
  else
    inspec.command("hostname#{opt}").stdout.chomp
  end
end