Sha256: 44b15d76a352bcc05cb07b694ccaf9517e2769fc34ed0fde642a7b3d0123a6b1

Contents?: true

Size: 683 Bytes

Versions: 16

Compression:

Stored size: 683 Bytes

Contents

# Fact: hostname
#
# Purpose: Return the system's short hostname.
#
# Resolution:
#   On all system bar 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

16 entries across 16 versions & 1 rubygems

Version Path
facter-2.1.0 lib/facter/hostname.rb
facter-2.1.0-x86-mingw32 lib/facter/hostname.rb
facter-2.1.0-x64-mingw32 lib/facter/hostname.rb
facter-2.1.0-universal-darwin lib/facter/hostname.rb
facter-2.0.2 lib/facter/hostname.rb
facter-2.0.2-x86-mingw32 lib/facter/hostname.rb
facter-2.0.2-universal-darwin lib/facter/hostname.rb
facter-2.0.1 lib/facter/hostname.rb
facter-2.0.1-x86-mingw32 lib/facter/hostname.rb
facter-2.0.1-universal-darwin lib/facter/hostname.rb
facter-2.0.1.rc4 lib/facter/hostname.rb
facter-2.0.1.rc4-x86-mingw32 lib/facter/hostname.rb
facter-2.0.1.rc4-universal-darwin lib/facter/hostname.rb
facter-2.0.1.rc3 lib/facter/hostname.rb
facter-2.0.1.rc3-x86-mingw32 lib/facter/hostname.rb
facter-2.0.1.rc3-universal-darwin lib/facter/hostname.rb