Jira (FACT-3076) Custom facts cannot reference external facts

21 views
Skip to first unread message

Robert Berry (Jira)

unread,
Sep 28, 2021, 8:25:03 AM9/28/21
to puppe...@googlegroups.com
Robert Berry created an issue
 
Facter / Bug FACT-3076
Custom facts cannot reference external facts
Issue Type: Bug Bug
Affects Versions: FACT 3.14.1
Assignee: Unassigned
Components: Facter 3
Created: 2021/09/28 5:24 AM
Priority: Normal Normal
Reporter: Robert Berry

https://puppet.com/docs/puppet/6/external_facts.html says

> Due to parse order, you can reference an external fact from a Ruby fact.

But this does not seem to work:

$ cat external/ext.yaml

shouting: 'HELLO'

$ cat custom/cust.rb
Facter.add('not_shouting') do
setcode do
Facter.value('shouting').downcase()
end
end

$ facter --external-dir external shouting
HELLO

$ facter --external-dir external --custom-dir custom not_shouting
2021-09-28 05:08:08.686159 ERROR puppetlabs.facter - error while resolving custom fact "not_shouting": undefined method `downcase' for nil:NilClass

The custom fact is loaded before external facts, and cannot resolve it:

$ facter --debug --external-dir external --custom-dir custom not_shouting
2021-09-28 05:08:14.428428 INFO puppetlabs.facter - executed with command line: --debug --external-dir external --custom-dir custom not_shouting.
2021-09-28 05:08:14.428594 DEBUG leatherman.ruby:513 - ruby was found at "/usr/bin/ruby".
2021-09-28 05:08:14.428740 DEBUG leatherman.execution:93 - executing command: /usr/bin/ruby -e print(['libdir', 'archlibdir', 'sitearchlibdir', 'bindir'].find do |name|dir = RbConfig::CONFIG[name];next unless dir;file = File.join(dir, RbConfig::CONFIG['LIBRUBY_SO']);break file if File.exist? file;false end)
2021-09-28 05:08:14.498854 DEBUG | - /usr/lib/x86_64-linux-gnu/libruby-2.7.so.2.7.4
2021-09-28 05:08:14.499154 DEBUG leatherman.execution:610 - process exited with status code 0.
2021-09-28 05:08:14.501242 INFO leatherman.ruby:139 - ruby loaded from "/usr/lib/x86_64-linux-gnu/libruby-2.7.so.2.7.4".
2021-09-28 05:08:14.501408 DEBUG leatherman.dynamic_library:77 - symbol rb_data_object_alloc not found in library /usr/lib/x86_64-linux-gnu/libruby-2.7.so.2.7.4, trying alias rb_data_object_wrap.
2021-09-28 05:08:14.568781 INFO leatherman.ruby:195 - using ruby version 2.7.4
2021-09-28 05:08:14.568945 INFO puppetlabs.facter - requested queries: not_shouting.
2021-09-28 05:08:14.569048 DEBUG puppetlabs.facter - fact "facterversion" has resolved to "3.14.12".
2021-09-28 05:08:14.569266 DEBUG leatherman.file_util:65 - Error reading file: No such file or directory
2021-09-28 05:08:14.569634 DEBUG puppetlabs.facter - loading all custom facts.
2021-09-28 05:08:14.569711 DEBUG puppetlabs.facter - loading custom fact directories from config file
2021-09-28 05:08:14.569779 DEBUG puppetlabs.facter - searching for custom facts in /tmp/custom.
2021-09-28 05:08:14.569886 INFO puppetlabs.facter - loading custom facts from /tmp/custom/cust.rb.
2021-09-28 05:08:14.570123 DEBUG puppetlabs.facter - loading external fact directories from config file
2021-09-28 05:08:14.570214 DEBUG leatherman.file_util:65 - Error reading file: No such file or directory
2021-09-28 05:08:14.570334 DEBUG puppetlabs.facter - custom fact "shouting" was not found.
2021-09-28 05:08:14.570957 ERROR puppetlabs.facter - error while resolving custom fact "not_shouting": undefined method `downcase' for nil:NilClass
2021-09-28 05:08:14.571054 DEBUG puppetlabs.facter - fact "not_shouting" resolved to null and will not be added.
2021-09-28 05:08:14.571150 DEBUG puppetlabs.facter - skipping external facts for "/usr/local/google/home/raa/.puppetlabs/opt/facter/facts.d": No such file or directory
2021-09-28 05:08:14.571256 DEBUG puppetlabs.facter - skipping external facts for "/usr/local/google/home/raa/.facter/facts.d": No such file or directory
2021-09-28 05:08:14.571334 DEBUG puppetlabs.facter - searching "/tmp/external" for external facts.
2021-09-28 05:08:14.571434 DEBUG puppetlabs.facter - resolving facts from YAML file "/tmp/external/ext.yaml".
2021-09-28 05:08:14.571696 DEBUG puppetlabs.facter - fact "shouting" has resolved to "HELLO".
2021-09-28 05:08:14.571780 DEBUG puppetlabs.facter - completed resolving facts from YAML file "/tmp/external/ext.yaml".
2021-09-28 05:08:14.571883 DEBUG puppetlabs.facter - fact "not_shouting" does not exist.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Sep 29, 2021, 8:50:03 PM9/29/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-3076
 
Re: Custom facts cannot reference external facts

Robert Berry do you get the same behavior with Puppet 7/Facter 4?

Robert Berry (Jira)

unread,
Sep 29, 2021, 10:07:03 PM9/29/21
to puppe...@googlegroups.com
Robert Berry commented on Bug FACT-3076

Hi Josh,

Our Puppet fleet is huge and the binaries are managed by multiple teams, depending on platform. We have not yet scoped the migration to Puppet 7/Facter 4.

Does Facter 4 include test cases for this behavior?

Thanks
Rob.

Robert Berry (Jira)

unread,
Sep 29, 2021, 10:11:02 PM9/29/21
to puppe...@googlegroups.com
Robert Berry commented on Bug FACT-3076

Or is there a way to modify the order of fact resolution in Facter 3?

I cannot find any mention of this in the manpage or config examples.

Ciprian Badescu (Jira)

unread,
Oct 6, 2021, 6:48:03 AM10/6/21
to puppe...@googlegroups.com

The problem is no longer reproducible with latest facter 4.

 

$ facter --external-dir ./FACT-3076/external --custom-dir `pwd`/FACT-3076/custom/ not_shouting
hello

 

 

Gabriel Nagy (Jira)

unread,
Oct 11, 2021, 10:39:02 AM10/11/21
to puppe...@googlegroups.com
Gabriel Nagy commented on Bug FACT-3076

Hey Robert Berry,

If you're using a recent enough version of Puppet 6, you can enable Facter 4 on a per-agent basis by setting facterng to true in puppet.conf (or on a per-run basis with puppet agent -t --facterng). We recommend you to be on the latest Puppet 6 version before you do this, so you benefit from the latest updates that went in Facter 4.

 

Robert Berry (Jira)

unread,
Oct 28, 2021, 2:43:02 AM10/28/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 9, 2023, 3:11:02 PM1/9/23
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-3076

Since Puppet 6/Facter 3 will be EOL at the end of February and Puppet 7/Facter 4 support the requested functionality, I'm going to close this as won't do.

This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages