Sha256: 5a2aa04d29551421a671b197e39e209ab5f4125d3c4a44c3290375fd71c8f3b4

Contents?: true

Size: 684 Bytes

Versions: 99

Compression:

Stored size: 684 Bytes

Contents

# Fact: hostname
#
# Purpose: Return the system's short hostname.
#
# Resolution:
#   On all systems but Darwin, parses the output of the `hostname` system command
#   to everything before the first period.
#   On Darwin, uses the system configuration util to get the LocalHostName
#   variable.
#
# Caveats:
#

Facter.add(:hostname) do
  setcode do
    hostname = nil
    if name = Facter::Core::Execution.execute('hostname')
      if name =~ /(.*?)\./
        hostname = $1
      else
        hostname = name
      end
    end
    hostname
  end
end

Facter.add(:hostname) do
  confine :kernel => :darwin, :kernelrelease => "R7"
  setcode '/usr/sbin/scutil --get LocalHostName'
end

Version data entries

99 entries across 99 versions & 2 rubygems

Version Path
facter-2.5.7 lib/facter/hostname.rb
facter-2.5.7-x86-mingw32 lib/facter/hostname.rb
facter-2.5.7-x64-mingw32 lib/facter/hostname.rb
facter-2.5.7-universal-darwin lib/facter/hostname.rb
facter-2.5.6-x86-mingw32 lib/facter/hostname.rb
facter-2.5.6-x64-mingw32 lib/facter/hostname.rb
facter-2.5.6-universal-darwin lib/facter/hostname.rb
facter-2.5.6 lib/facter/hostname.rb
facter-2.5.5-x86-mingw32 lib/facter/hostname.rb
facter-2.5.5-x64-mingw32 lib/facter/hostname.rb
facter-2.5.5-universal-darwin lib/facter/hostname.rb
facter-2.5.5 lib/facter/hostname.rb
facter-2.5.4-x86-mingw32 lib/facter/hostname.rb
facter-2.5.4-x64-mingw32 lib/facter/hostname.rb
facter-2.5.4-universal-darwin lib/facter/hostname.rb
facter-2.5.4 lib/facter/hostname.rb
bolt-0.24.0 vendored/facter/lib/facter/hostname.rb
bolt-0.23.0 vendored/facter/lib/facter/hostname.rb
bolt-0.22.0 vendored/facter/lib/facter/hostname.rb
bolt-0.21.8 vendored/facter/lib/facter/hostname.rb