After updating puppet to verision 6.18.0-1, the following script, located in `/opt/puppetlabs/facter/facts.d/` recurses into oblivion
{noformat}#!/usr/bin/env ruby require 'json' osfamily = %x(/opt/puppetlabs/bin/facter --no-custom-facts --no-external-facts os.family).strip @data = { packages: {} } def parse_redhat packagelist = %x(rpm -qa --qf '%{NAME};%{VERSION}-%{RELEASE}\n').split("\n") packagelist.each do |package| pname = package.split(';').first version = package.split(';').last @data[:packages][pname] = version.strip end end def parse_debian packagelist = %x(dpkg-query -W -f='${binary:Package};${Version}\n').split("\n") packagelist.each do |package| pname = package.split(';').first version = package.split(';').last @data[:packages][pname] = version.strip end end if osfamily == 'RedHat' parse_redhat end if osfamily == 'Debian' parse_debian end puts @data.to_json {noformat}
I created this ticket after I talked to the slack community puppet guy Josh ([https://puppetcommunity.slack.com/archives/C0W298S9G/p1598386635326500)] {quote}"@kervyn facter 3.x (which is the default in puppet 6) has logic to prevent external facts from calling facter recursively (FACT-1373) but it seems that's not working as expected. Can you file a FACT ticket and link the 1373?" {quote}
For this ticket, Facter 4 should check if the INSIDE_FACTER environment variable is set prior to evaluating external facts. If it's not set, then set the variable. See how this is implemented in facter 3 https://github.com/puppetlabs/facter/blob/6d7ffc6efdfbc3b1fc79311cdeb4581ac2098d9c/exe/facter.cc#L282-L293 If recursion is detected, facter would emit an error similar to "Facter was called recursively, skipping external facts. Add '--no-external-facts' to silence this warning" and it should automatically ignore external facts.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppe...@googlegroups.com
If it's not set, then set the variable, see how this is implemented in facter 3 https://github.com/puppetlabs/facter/blob/6d7ffc6efdfbc3b1fc79311cdeb4581ac2098d9c/exe/facter.cc#L282-L293 If recursion is detected, facter should emit an error similar to "Facter was called recursively, skipping external facts. Add '--no-external-facts' to silence this warning" and it should automatically ignore external facts. You may want to implement this in {{lib/facter/framework/cli/cli.rb}} Need to account for different ways facter can be called (via command line, puppet, to_hash, resolve(''), resolve('os.family')). Create additional tickets as needed.
Facter 3 guarded against recursive calls to facter inside external facts; this has now been added to Facter 4. If an external fact calls out to facter without specifying the no-external-facts, facter will warn the user and skip falling into calling facter recursively.