Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5109

Puppet::Resource::Catalog::Compiler#set_server_facts always produces a warning on ipv6 only systems

    Details

    • Release Notes:
      Enhancement
    • Release Notes Summary:
      This adds the serverip6 fact holding the servers IPv6 address. The user will receive a warning if puppet cannot find either serverip or serverip6 facts, but not if one or both are found.

      Description

      When compiling a catalogue for an IPv6-only system such as

      igalic@mydb02 ~> ip a
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host 
             valid_lft forever preferred_lft forever
      2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
          link/ether 52:54:00:ba:b8:17 brd ff:ff:ff:ff:ff:ff
          inet6 2a01:4f8:211:9d6::14/64 scope global 
             valid_lft forever preferred_lft forever
          inet6 fe80::5054:ff:feba:b817/64 scope link 
             valid_lft forever preferred_lft forever
      igalic@mydb02 ~>
      

      puppet will throw the warning: Warning: Could not retrieve fact ipaddress

      Given that the code that produces this warning has a fallback for some nil? values, perhaps it's not necessary to issue a warning at all, and instead just add another .nil? case:

        # Initialize our server fact hash; we add these to each client, and they
        # won't change while we're running, so it's safe to cache the values.
        def set_server_facts
          @server_facts = {}
       
          # 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"
          }.each do |var, fact|
            @server_facts[var] = value if value = Facter.value(fact)
          end
       
          if @server_facts["servername"].nil?
            host = Facter.value(:hostname)
            if domain = Facter.value(:domain)
              @server_facts["servername"] = [host, domain].join(".")
            else
              @server_facts["servername"] = host
            end
          end
          if @server_facts["serverip"].nil?
            @server_facts["serverip"] = Facter.value(:ipaddress6)
          end
        end
      

        Attachments

          Activity

            People

            • Assignee:
              kris.bosland Kris Bosland
              Reporter:
              igalic Igor Galić
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support