Jira (FACT-1846) inconsistent results between facter and puppet facts

12 views
Skip to first unread message

Thomas Kishel (JIRA)

unread,
Apr 20, 2018, 1:40:04 PM4/20/18
to puppe...@googlegroups.com
Thomas Kishel created an issue
 
Facter / Bug FACT-1846
inconsistent results between facter and puppet facts
Issue Type: Bug Bug
Affects Versions: FACT 3.9.5
Assignee: Unassigned
Created: 2018/04/20 10:39 AM
Environment:

Here is an example:

Given:

cat /etc/puppetlabs/facter/facts.d/test.txt
 
nil_test_DEFLT=EXTERNAL
nil_test_00000=EXTERNAL
nil_test_00099=EXTERNAL
nil_test_00100=EXTERNAL
nil_test_10001=EXTERNAL
#
str_test_DEFLT=EXTERNAL
str_test_00000=EXTERNAL
str_test_00099=EXTERNAL
str_test_00100=EXTERNAL
str_test_10001=EXTERNAL

cat /opt/puppetlabs/puppet/cache/lib/facter/test.rb
 
Facter.add('nil_test_DEFLT') do
  setcode do
    nil
  end
end
Facter.add('nil_test_00000') do
  has_weight 0
  setcode do
    nil
  end
end
Facter.add('nil_test_00099') do
  has_weight 99
  setcode do
    nil
  end
end
Facter.add('nil_test_00100') do
  has_weight 100
  setcode do
    nil
  end
end
Facter.add('nil_test_10001') do
  has_weight 10001
  setcode do
    nil
  end
end
#
Facter.add('str_test_DEFLT') do
  setcode do
    'CUSTOM'
  end
end
Facter.add('str_test_00000') do
  has_weight 0
  setcode do
    'CUSTOM'
  end
end
Facter.add('str_test_00099') do
  has_weight 99
  setcode do
    'CUSTOM'
  end
end
Facter.add('str_test_00100') do
  has_weight 100
  setcode do
    'CUSTOM'
  end
end
Facter.add('str_test_10001') do
  has_weight 10001
  setcode do
    'CUSTOM'
  end
end

Results:

facter -p | grep nil_test
 
nil_test_00000 => EXTERNAL
nil_test_00099 => EXTERNAL
nil_test_00100 => EXTERNAL
nil_test_10001 => EXTERNAL
nil_test_deflt => EXTERNAL
 
facter -p | grep str_test
 
str_test_00000 => EXTERNAL
str_test_00099 => EXTERNAL
str_test_00100 => EXTERNAL
str_test_10001 => CUSTOM
str_test_deflt => EXTERNAL
 
puppet facts find | grep nil_test | sed 's/^[ \t]*//'
 
"nil_test_00000": "EXTERNAL",
"nil_test_deflt": "EXTERNAL",
 
puppet facts find | grep str_test | sed 's/^[ \t]*//'
 
"str_test_00000": "EXTERNAL",
"str_test_00099": "EXTERNAL",
"str_test_00100": "EXTERNAL",
"str_test_10001": "CUSTOM",
"str_test_deflt": "EXTERNAL",

Priority: Normal Normal
Reporter: Thomas Kishel

facter -p and puppet facts return different results when:

  • using a combination of an external and a custom fact with a default has_weight or has_weight > 0
  • the custom fact value is nil

  

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Thomas Kishel (JIRA)

unread,
Apr 20, 2018, 1:41:02 PM4/20/18
to puppe...@googlegroups.com
Thomas Kishel updated an issue
Change By: Thomas Kishel
Environment:
Here is an example:

Given:
{code:java}cat /etc/puppetlabs/facter/facts.d/test.txt


nil_test_DEFLT=EXTERNAL
nil_test_00000=EXTERNAL
nil_test_00099=EXTERNAL
nil_test_00100=EXTERNAL
nil_test_10001=EXTERNAL
#
str_test_DEFLT=EXTERNAL
str_test_00000=EXTERNAL
str_test_00099=EXTERNAL
str_test_00100=EXTERNAL
str_test_10001=EXTERNAL
{code}
{code:java}cat /opt/puppetlabs/puppet/cache/lib/facter/test.rb
{code}
Results:
{code:java}facter -p | grep nil_test


nil_test_00000 => EXTERNAL
nil_test_00099 => EXTERNAL
nil_test_00100 => EXTERNAL
nil_test_10001 => EXTERNAL
nil_test_deflt => EXTERNAL

facter -p | grep str_test

str_test_00000 => EXTERNAL
str_test_00099 => EXTERNAL
str_test_00100 => EXTERNAL
str_test_10001 => CUSTOM
str_test_deflt => EXTERNAL

puppet facts find | grep nil_test | sed 's/^[ \t]*//'

"nil_test_00000": "EXTERNAL",
"nil_test_deflt": "EXTERNAL",

puppet facts find | grep str_test | sed 's/^[ \t]*//'

"str_test_00000": "EXTERNAL",
"str_test_00099": "EXTERNAL",
"str_test_00100": "EXTERNAL",
"str_test_10001": "CUSTOM",
"str_test_deflt": "EXTERNAL",
{code}

Thomas Kishel (JIRA)

unread,
Apr 20, 2018, 1:41:03 PM4/20/18
to puppe...@googlegroups.com

cat /etc/puppetlabs/facter/facts.d/test.txt
 
nil_test_DEFLT=EXTERNAL
nil_test_00000=EXTERNAL
nil_test_00099=EXTERNAL
nil_test_00100=EXTERNAL
nil_test_10001=EXTERNAL
#
str_test_DEFLT=EXTERNAL
str_test_00000=EXTERNAL
str_test_00099=EXTERNAL
str_test_00100=EXTERNAL
str_test_10001=EXTERNAL

Results:

facter -p | grep nil_test
 
nil_test_00000 => EXTERNAL
nil_test_00099 => EXTERNAL
nil_test_00100 => EXTERNAL
nil_test_10001 => EXTERNAL
nil_test_deflt => EXTERNAL
 
facter -p | grep str_test
 
str_test_00000 => EXTERNAL
str_test_00099 => EXTERNAL
str_test_00100 => EXTERNAL
str_test_10001 => CUSTOM
str_test_deflt => EXTERNAL
 
puppet facts find | grep nil_test | sed 's/^[ \t]*//'
 
"nil_test_00000": "EXTERNAL",
"nil_test_deflt": "EXTERNAL",
 
puppet facts find | grep str_test | sed 's/^[ \t]*//'
 
"str_test_00000": "EXTERNAL",
"str_test_00099": "EXTERNAL",
"str_test_00100": "EXTERNAL",
"str_test_10001": "CUSTOM",
"str_test_deflt": "EXTERNAL",

Thomas Kishel (JIRA)

unread,
Apr 20, 2018, 1:43:01 PM4/20/18
to puppe...@googlegroups.com

Research ...

Fact precedence with default weights:

  1. external fact (highest precedence)
  2. custom fact
  3. environment fact
  4. core fact (lowest precedence)

External facts are assigned an inherent weight of 10000.
A custom fact with "has_weight" > 10000 will override an external fact with the same name.
A custom fact with "has_weight" = 0 will be overriden by an environment or core fact with the same name.
When a fact has more than one resolution, the first resolution that returns a value other than nil sets the fact’s value.

Branan Riley (JIRA)

unread,
May 1, 2018, 5:18:05 PM5/1/18
to puppe...@googlegroups.com

Branan Riley (JIRA)

unread,
May 21, 2018, 4:04:02 PM5/21/18
to puppe...@googlegroups.com

Branan Riley (JIRA)

unread,
May 21, 2018, 4:04:04 PM5/21/18
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Oct 14, 2020, 7:55:02 AM10/14/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: ready for triage
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

unread,
Oct 14, 2020, 7:55:03 AM10/14/20
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Team: Platform OS Night's Watch

Mihai Buzgau (Jira)

unread,
Oct 14, 2020, 7:55:03 AM10/14/20
to puppe...@googlegroups.com

Sebastian Miclea (Jira)

unread,
Oct 14, 2020, 9:15:03 AM10/14/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Oct 14, 2020, 10:06:02 AM10/14/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ready for triage ghost-21.10

Andrei Filipovici (Jira)

unread,
Oct 19, 2020, 6:52:02 AM10/19/20
to puppe...@googlegroups.com

Andrei Filipovici (Jira)

unread,
Oct 20, 2020, 10:50:08 AM10/20/20
to puppe...@googlegroups.com
Andrei Filipovici commented on Bug FACT-1846
 
Re: inconsistent results between facter and puppet facts

Tested the above example with puppet-agent 6.20.0, facter 3.14.14.

Instead of puppet facts find, we use puppet facts show. This action is more configurable (supports all the arguments that facter does, and can be called to retrieve only a fact or a list of facts).

facter -p | grep nil_test
 
2020-10-20 14:44:38.661985 WARN  puppetlabs.facter - skipping external facts for "/opt/puppetlabs/puppet/cache/facts.d": No such file or directory
nil_test_00000 => EXTERNAL
nil_test_00099 => EXTERNAL
nil_test_00100 => EXTERNAL
nil_test_10001 => EXTERNAL
nil_test_deflt => EXTERNAL
 
facter -p | grep str_test
 
2020-10-20 14:45:15.978305 WARN  puppetlabs.facter - skipping external facts for "/opt/puppetlabs/puppet/cache/facts.d": No such file or directory
str_test_00000 => EXTERNAL
str_test_00099 => EXTERNAL
str_test_00100 => EXTERNAL
str_test_10001 => CUSTOM
str_test_deflt => EXTERNAL
 
 
puppet facts show | grep nil_test | sed 's/^[ \t]*//'
 
"nil_test_00000": "EXTERNAL",
"nil_test_00099": "EXTERNAL",
"nil_test_00100": "EXTERNAL",
"nil_test_10001": "EXTERNAL",
"nil_test_deflt": "EXTERNAL",
 
puppet facts show | grep str_test | sed 's/^[ \t]*//'
 
"str_test_00000": "EXTERNAL",
"str_test_00099": "EXTERNAL",
"str_test_00100": "EXTERNAL",
"str_test_10001": "CUSTOM",
"str_test_deflt": "EXTERNAL",

As a side note, the -p option is obsolete in facter 4 and will be removed.

Bogdan Irimie (Jira)

unread,
Oct 21, 2020, 9:11:03 AM10/21/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-21.10 , PR - Triage 2
Reply all
Reply to author
Forward
0 new messages