custom_fact broke with 7.x (Facter.puppet_vardir)

43 views
Skip to first unread message

Denny Fuchs

unread,
Feb 1, 2024, 6:56:46 AMFeb 1
to Puppet Users
Hi,

we use a custom fact, that gives us the loaded puppet moduels and loaded puppet classes. With Debian Bookworm it breaks:

Notice: /File[/var/cache/puppet/lib/facter/classes.rb]/content: content changed '{sha256}ca4b2b426bf27e0176a993ce39c7c64796996c90430a8712da30514fb914aea8' to '{sha256}b3540b60fd4cf67d7d4aeb762d0c7709d135eed82ad01cf13a2b8b28947a66e7'
Info: Loading facts
Error: Facter: --puppet_vardir-- not implemented but required
with params: []
with block: nil  
called by:  
["/var/cache/puppet/lib/facter/classes.rb:7:in `<top (required)>'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:115:in `load'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:115:in `kernel_load'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:98:in `load_file'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:47:in `block (2 levels) in load_all'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:45:in `each'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:45:in `block in load_all'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:41:in `each'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/loader.rb:41:in `load_all'", "/usr/lib/ruby/vendor_ruby/facter/custom_facts/util/collection.rb:118:in `custom_facts'", "/usr/lib/ruby/vendor_ruby/facter/framework/core/fact_loaders/external_fact_loader.rb:20:in `load_custom_facts'", "/usr/lib/ruby/vendor_ruby/facter/framework/core/fact_loaders/external_fact_loader.rb:6:in `custom_facts'", "/usr/lib/ruby/vendor_ruby/facter/framework/core/fact_loaders/fact_loader.rb:56:in `load_custom_facts'", "/usr/lib/ruby/vendor_ruby/facter/framework/core/fact_loaders/fact_loader.rb:23:in `load'", "/usr/lib/ruby/vendor_ruby/facter/framework/core/fact_manager.rb:20:in `resolve_facts'", "/usr/lib/ruby/vendor_ruby/facter.rb:380:in `to_hash'", "/usr/lib/ruby/vendor_ruby/puppet/facter_impl.rb:25:in `to_hash'", "/usr/lib/ruby/vendor_ruby/puppet/indirector/facts/facter.rb:40:in `find'", "/usr/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:223:in `find'", "/usr/lib/ruby/vendor_ruby/puppet/configurer/fact_handler.rb:15:in `find_facts'", "/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:241:in `block in get_facts'", "/usr/lib/ruby/vendor_ruby/puppet/util.rb:567:in `block in thinmark'", "/usr/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'", "/usr/lib/ruby/vendor_ruby/puppet/util.rb:566:in `thinmark'", "/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:240:in `get_facts'", "/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:423:in `run_internal'", "/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:339:in `run'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:83:in `block (6 levels) in run'", "/usr/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'", "/usr/lib/ruby/vendor_ruby/puppet.rb:289:in `override'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:82:in `block (5 levels) in run'", "/usr/lib/ruby/3.1.0/timeout.rb:107:in `block in timeout'", "/usr/lib/ruby/3.1.0/timeout.rb:117:in `timeout'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:81:in `block (4 levels) in run'", "/usr/lib/ruby/vendor_ruby/puppet/agent/locker.rb:21:in `lock'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:71:in `block (3 levels) in run'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:162:in `with_client'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:67:in `block (2 levels) in run'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:127:in `run_in_fork'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:66:in `block in run'", "/usr/lib/ruby/vendor_ruby/puppet/application.rb:172:in `controlled_run'", "/usr/lib/ruby/vendor_ruby/puppet/agent.rb:47:in `run'", "/usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:433:in `onetime'", "/usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:393:in `block in run_command'", "/usr/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'", "/usr/lib/ruby/vendor_ruby/puppet.rb:289:in `override'", "/usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:390:in `run_command'", "/usr/lib/ruby/vendor_ruby/puppet/application.rb:421:in `block in run'", "/usr/lib/ruby/vendor_ruby/puppet/util.rb:756:in `exit_on_fail'", "/usr/lib/ruby/vendor_ruby/puppet/application.rb:421:in `run'", "/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:143:in `run'", "/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'", "/usr/bin/puppet:5:in `<main>'"]



The line, where it breaks is:

Facter.puppet_vardir

can someone give me a hint, how we can solve it ?

the full fact is:

#!/usr/bin/env ruby
# Puppet classes and modules as facts
# Source: modules/custom/lib/facter/classes.rb

require 'facter'
begin
  Facter.puppet_vardir
rescue
  Facter.loadfacts()
end

vardir=Facter.value("puppet_vardir")
statedir="#{vardir}/state"
classes_file="#{statedir}/classes.txt"

if File.exists?(classes_file)
  #File exists, load it.
  f=File.open(classes_file, 'r')
  classes_hash  = {}
  modules_array = []
  File.foreach(classes_file) do |l|
    modules_array << l.chomp.gsub(/::.*/, '')
  end

  modules_array = modules_array.sort.uniq
  modules_array.each do |i|
    classes_array = []
    classes_array << i
    File.foreach(classes_file) do |l|
      classes_array << l.chomp if l =~ /^#{i}/
      classes_array = classes_array.sort.uniq
    end
    classes_hash[i] = classes_array
  end
 
  Facter.add(:puppet_modules) do
    confine :kernel => 'Linux'
    setcode do
      modules_array.sort.uniq.join(', ').to_s
    end
  end
  Facter.add(:puppet_classes) do
    confine :kernel => 'Linux'
    setcode do
      classes_hash.map { |_k, v| v }.sort.uniq.join(', ').to_s
    end
  end
end



cu denny

Reply all
Reply to author
Forward
0 new messages