Sha256: 920994d1a843a127da9e0dd42956a12f5ef44f31b13a8cc16c7ad1ba1cf8326b

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

class Puppet::Node::ServerFacts
  def self.load
    server_facts = {}

    # Add our server Puppet Enterprise version, if available.
    pe_version_file = '/opt/puppetlabs/server/pe_version'
    if File.readable?(pe_version_file) and !File.zero?(pe_version_file)
      server_facts['pe_serverversion'] = File.read(pe_version_file).chomp
    end

    # Add our server version to the fact list
    server_facts["serverversion"] = Puppet.version.to_s

    # And then add the server name and IP
    {"servername" => "fqdn",
      "serverip"  => "ipaddress",
      "serverip6" => "ipaddress6"}.each do |var, fact|
      value = Puppet.runtime[:facter].value(fact)
      if !value.nil?
        server_facts[var] = value
      end
    end

    if server_facts["servername"].nil?
      host = Puppet.runtime[:facter].value(:hostname)
      if host.nil?
        Puppet.warning _("Could not retrieve fact servername")
      elsif domain = Puppet.runtime[:facter].value(:domain) #rubocop:disable Lint/AssignmentInCondition
        server_facts["servername"] = [host, domain].join(".")
      else
        server_facts["servername"] = host
      end
    end

    if server_facts["serverip"].nil? && server_facts["serverip6"].nil?
      Puppet.warning _("Could not retrieve either serverip or serverip6 fact")
    end

    server_facts
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-7.34.0 lib/puppet/node/server_facts.rb
puppet-7.34.0-x86-mingw32 lib/puppet/node/server_facts.rb
puppet-7.34.0-x64-mingw32 lib/puppet/node/server_facts.rb
puppet-7.34.0-universal-darwin lib/puppet/node/server_facts.rb
puppet-7.33.0 lib/puppet/node/server_facts.rb
puppet-7.33.0-x86-mingw32 lib/puppet/node/server_facts.rb
puppet-7.33.0-x64-mingw32 lib/puppet/node/server_facts.rb
puppet-7.33.0-universal-darwin lib/puppet/node/server_facts.rb
puppet-7.32.1 lib/puppet/node/server_facts.rb
puppet-7.32.1-x86-mingw32 lib/puppet/node/server_facts.rb
puppet-7.32.1-x64-mingw32 lib/puppet/node/server_facts.rb
puppet-7.32.1-universal-darwin lib/puppet/node/server_facts.rb