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

"puppet facts show fact" output differs from "facter fact"

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • PUP 7.1.0
    • PUP 7.3.0
    • UX
    • Night's Watch
    • ghost-13.01.2020, ghost-27.01.2021
    • Needs Assessment
    • Bug Fix
    • Hide
      Description of the problem: The output format is different between Facter and puppet facts when a query for a single fact is provided:
      ~~ puppet facts facterversion
      { "facterversion": "4.0.47" }
      vs
      ~~ facter facterversion
      4.0.47
      Description of the fix:
      Added --value-only command argument:
      When there is a single query, only display the value of the fact without it's name:
      ~~ puppet facts facterversion --value-only
      "4.0.47"
      Also this generates a warning message if the argument is used with multiple queries or with no query at all:
      puppet facts show facterversion os --value-only
      Warning: Incorrect use of --value-only argument! The argument can only be used when querying for a single fact

      Added flat render format:
      When there is a query for a simple fact:
      puppet facts show facterversion --render-as flat
      facterversion=4.0.47
      and with --value-only
      puppet facts show facterversion --render-as flat --value-only
      4.0.47

      When there is a query for a more complex fact (ex. os) the output will be:

      ~~ puppet facts os --render-as flat
      os.architecture=x86_64
      os.family=Darwin
      os.hardware=x86_64
      os.macosx.build=18G95
      os.macosx.product=Mac OS X
      os.macosx.version.full=10.14.6
      os.macosx.version.major=10.14
      os.macosx.version.minor=6
      os.name=Darwin
      os.release.full=18.7.0
      os.release.major=18
      os.release.minor=7
      and with --value-only

      ~~ puppet facts os --render-as flat --value-only
      architecture=x86_64
      family=Darwin
      hardware=x86_64
      macosx.build=18G95
      macosx.product=Mac OS X
      macosx.version.full=10.14.6
      macosx.version.major=10.14
      macosx.version.minor=6
      name=Darwin
      release.full=18.7.0
      release.major=18
      release.minor=7
      For multiple user queries the output is :

      ~~ puppet facts show os.name facterversion --render-as flat
      facterversion=4.0.47
      os.name=Darwin
      When the result is an array, the index of each element is also displayed:

      ~~ puppet facts show processors.models --render-as flat
      processors.models.0=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.1=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.2=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.3=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.4=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.5=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.6=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      processors.models.7=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
      ~~ puppet facts show networking.interfaces.interface_name.bindings6 --render-as flat --value-only
      0.address=fe80::...
      0.netmask=ffff:ffff:ffff:ffff::
      0.network=fe80::
      0.scope6=link
      Show
      Description of the problem: The output format is different between Facter and puppet facts when a query for a single fact is provided: ~~ puppet facts facterversion { "facterversion": "4.0.47" } vs ~~ facter facterversion 4.0.47 Description of the fix: Added --value-only command argument: When there is a single query, only display the value of the fact without it's name: ~~ puppet facts facterversion --value-only "4.0.47" Also this generates a warning message if the argument is used with multiple queries or with no query at all: puppet facts show facterversion os --value-only Warning: Incorrect use of --value-only argument! The argument can only be used when querying for a single fact Added flat render format: When there is a query for a simple fact: puppet facts show facterversion --render-as flat facterversion=4.0.47 and with --value-only puppet facts show facterversion --render-as flat --value-only 4.0.47 When there is a query for a more complex fact (ex. os) the output will be: ~~ puppet facts os --render-as flat os.architecture=x86_64 os.family=Darwin os.hardware=x86_64 os.macosx.build=18G95 os.macosx.product=Mac OS X os.macosx.version.full=10.14.6 os.macosx.version.major=10.14 os.macosx.version.minor=6 os.name=Darwin os.release.full=18.7.0 os.release.major=18 os.release.minor=7 and with --value-only ~~ puppet facts os --render-as flat --value-only architecture=x86_64 family=Darwin hardware=x86_64 macosx.build=18G95 macosx.product=Mac OS X macosx.version.full=10.14.6 macosx.version.major=10.14 macosx.version.minor=6 name=Darwin release.full=18.7.0 release.major=18 release.minor=7 For multiple user queries the output is : ~~ puppet facts show os.name facterversion --render-as flat facterversion=4.0.47 os.name=Darwin When the result is an array, the index of each element is also displayed: ~~ puppet facts show processors.models --render-as flat processors.models.0=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.1=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.2=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.3=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.4=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.5=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.6=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz processors.models.7=Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz ~~ puppet facts show networking.interfaces.interface_name.bindings6 --render-as flat --value-only 0.address=fe80::... 0.netmask=ffff:ffff:ffff:ffff:: 0.network=fe80:: 0.scope6=link
    • Needs Assessment

    Description

      Puppet Version: 7.1
      OS Name/Version: macOS 11.1

      The output of "puppet facts show somefact" is not the same as "facter somefact", as it returns JSON, which requires subsequent parsing to get the the fact value.

      We use "facter --puppet somefact" quite a bit in non-puppet code, such as shell and python scripts and other internal management utilities. This is a strongly complicating issue in a migration from facter 3/puppet 6 to facter 4/puppet 7: "facter --puppet" no longer works in Facter 4, and I believe "puppet facts show somefact" only works in Puppet 7.

      This will mean all the various places we use "facter --puppet somefact" will have to have a case on the puppet version and then call "facter --puppet somefact" or "puppet facts show somefact" as appropriate. And we'll have to do extra processing on the output of "puppet facts show", as it sends JSON.

      Desired Behavior:

      $ puppet facts show facterversion
      4.0.47
      $ facter facterversion
      4.0.47

      Actual Behavior:

      $ puppet facts show facterversion
      {
      "facterversion": "4.0.47"
      }
      $ facter facterversion
      4.0.47

      Attachments

        Activity

          People

            oana.tanasoiu Oana Tanasoiu
            ccaviness Clay Caviness
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support