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

puppet lookup --facts {filename} fails if filename does not contain a dot

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • PUP 6.23.0
    • PUP 7.13.0, PUP 6.26.0
    • None
    • Night's Watch
    • 2
    • NW - 2021-10-20, NW - 2021-11-03
    • Needs Assessment
    • Bug Fix
    • Hide
      Before this release, `puppet lookup --facts {filename}` failed early when the filename given did not contain a dot. This fix removes the early extensions check and adds a fallback instead — tries both formats (JSON then YAML) to read the given facts file when its path doesn't end with any of the expected extensions (yaml/yml/json). Otherwise, it follows previous implementation and respects given extension.
      Show
      Before this release, `puppet lookup --facts {filename}` failed early when the filename given did not contain a dot. This fix removes the early extensions check and adds a fallback instead — tries both formats (JSON then YAML) to read the given facts file when its path doesn't end with any of the expected extensions (yaml/yml/json). Otherwise, it follows previous implementation and respects given extension.
    • Needs Assessment

    Description

      Calling:

      puppet lookup --facts dummy keyX
      Error: Could not parse application options: undefined method `[]' for nil:NilClass
      

      Fails because the code that verifies the filename expects, that the filename contains a dot:

        option('--facts FACT_FILE') do |arg|
          if %w{.yaml .yml .json}.include?(arg.match(/\.[^.]*$/)[0])
            options[:fact_file] = arg
          else
            raise _("The --fact file only accepts yaml and json files.\n%{run_help}") % { run_help: RUN_HELP }
          end
        end
      

      Also, verifying based on the filename that the file contains json/yaml data is not correct in my opinion. In my opinion, the following should also be supported:

      puppet lookup --facts <(puppet facts find $nodename | jq .values) --node $nodename keyX
      

      Attachments

        Activity

          People

            luchian.nemes Luchian Nemes
            vicinus Reinhard Vicinus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support