Jira (FACT-2918) FACTER_ environmental facts overrides don't work with external facts

0 views
Skip to first unread message

Henry Wang (Jira)

unread,
Jan 14, 2021, 2:28:04 AM1/14/21
to puppe...@googlegroups.com
Henry Wang created an issue
 
Facter / Bug FACT-2918
FACTER_ environmental facts overrides don't work with external facts
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/01/13 11:27 PM
Environment:

PE 2019.8.4

Priority: Normal Normal
Reporter: Henry Wang

Overriding external facts from the cli works with facter but not in puppet.

Reproducing steps:

when the external fact things don't exist:

[root@goat01 facts.d]# pwd
/etc/puppetlabs/facter/facts.d
[root@goat01 facts.d]# ll things.txt
ls: cannot access things.txt: No such file or directory
[root@goat01 facts.d]# facter -p things
[root@goat01 facts.d]# FACTER_things=stuff facter -p things
stuff
[root@goat01 facts.d]# FACTER_things=stuff puppet facts|grep things
"things": "stuff",
[root@goat01 facts.d]# FACTER_things=stuff puppet apply -e 'notify{"things=>${facts.get(things)}<":}'
Notice: Compiled catalog for goat01.unix.gsm1900.org in environment production in 0.02 seconds
Notice: things=>stuff<
Notice: /Stage[main]/Main/Notify[things=>stuff<]/message: defined 'message' as 'things=>stuff<'
Notice: Applied catalog in 0.06 seconds

however, when external facts exist. create external fact things with value 'NOT_STUFF':

[root@goat01 facts.d]# echo things=NOT_STUFF > things.txt[root@goat01 facts.d]# facter -p things
NOT_STUFF[root@goat01 facts.d]# FACTER_things=stuff facter -p things #<-- works
stuff[root@goat01 facts.d]# FACTER_things=stuff puppet facts|grep things #<-- doesnt
"things": "NOT_STUFF",[root@goat01 facts.d]# FACTER_things=stuff puppet apply -e 'notify{"things=>${facts.get(things)}<":}'
Notice: Compiled catalog for goat01.unix.gsm1900.org in environment production in 0.02 seconds
Notice: things=>NOT_STUFF<
Notice: /Stage[main]/Main/Notify[things=>NOT_STUFF<]/message: defined 'message' as 'things=>NOT_STUFF<'
Notice: Applied catalog in 0.06 seconds 

Conclusion: when external facts exist, environment facts FACTER_<fact> will not overwrite the external facts in Puppet run. facter -p can display the overwritten value but puppet facts and puppet run can't.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Henry Wang (Jira)

unread,
Jan 14, 2021, 2:30:04 AM1/14/21
to puppe...@googlegroups.com
Henry Wang updated an issue
Change By: Henry Wang
Overriding Using cli, overriding external facts from the cli works with facter but not in puppet.


Reproducing steps:

when the external fact things don't exist:
{code:java}
[root@goat01 facts.d]# pwd
/etc/puppetlabs/facter/facts.d
[root@goat01 facts.d]# ll things.txt
ls: cannot access things.txt: No such file or directory
[root@goat01 facts.d]# facter -p things
[root@goat01 facts.d]# FACTER_things=stuff facter -p things
stuff
[root@goat01 facts.d]# FACTER_things=stuff puppet facts|grep things
"things": "stuff",
[root@goat01 facts.d]# FACTER_things=stuff puppet apply -e 'notify{"things=>${facts.get(things)}<":}'
Notice: Compiled catalog for goat01.unix.gsm1900.org in environment production in 0.02 seconds
Notice: things=>stuff<
Notice: /Stage[main]/Main/Notify[things=>stuff<]/message: defined 'message' as 'things=>stuff<'
Notice: Applied catalog in 0.06 seconds{code}

however, when external facts exist. create external fact things with value 'NOT_STUFF':
{code:java}
[root@goat01 facts.d]# echo things=NOT_STUFF > things.txt[root@goat01 facts.d]# facter -p things
NOT_STUFF[root@goat01 facts.d]# FACTER_things=stuff facter -p things #<-- works
stuff[root@goat01 facts.d]# FACTER_things=stuff puppet facts|grep things #<-- doesnt
"things": "NOT_STUFF",[root@goat01 facts.d]# FACTER_things=stuff puppet apply -e 'notify{"things=>${facts.get(things)}<":}'
Notice: Compiled catalog for goat01.unix.gsm1900.org in environment production in 0.02 seconds
Notice: things=>NOT_STUFF<
Notice: /Stage[main]/Main/Notify[things=>NOT_STUFF<]/message: defined 'message' as 'things=>NOT_STUFF<'
Notice: Applied catalog in 0.06 seconds {code}
Conclusion:
using cli, when external facts exist, environment facts FACTER_<fact> will not overwrite the external facts in Puppet run. facter -p can display the overwritten value but puppet facts and puppet run can't.

zendesk.jira (Jira)

unread,
Jan 14, 2021, 2:31:04 AM1/14/21
to puppe...@googlegroups.com

zendesk.jira (Jira)

unread,
Jan 14, 2021, 2:31:05 AM1/14/21
to puppe...@googlegroups.com
zendesk.jira updated an issue
Change By: zendesk.jira
Zendesk Ticket Count: 1
Zendesk Ticket IDs: 42719

Mihai Buzgau (Jira)

unread,
Jan 19, 2021, 6:03:04 AM1/19/21
to puppe...@googlegroups.com

Nick Walker (Jira)

unread,
Jan 19, 2021, 10:48:04 AM1/19/21
to puppe...@googlegroups.com
Nick Walker commented on Bug FACT-2918
 
Re: FACTER_ environmental facts overrides don't work with external facts

While this is inconsistent behavior... it's unclear what use case makes this a problem over just setting an external fact in a file.  The recommendation is just to set the external fact in a file to get it to show in the puppet run.  

We don't intend to fix this as when running from the puppet daemon setting facts from environment variables is likely not an expected use case.  

 

Kenneth Pepiton (Jira)

unread,
Jan 19, 2021, 2:44:04 PM1/19/21
to puppe...@googlegroups.com

There are two major problems with this response:
1) This was previously working and is no longer working
2) The exact use case is in the example.  The need to override the fact values while testing the agent allows for an alternative for testing.

I am very sadly disappointed in this type of response

Nick Walker (Jira)

unread,
Jan 20, 2021, 1:26:03 PM1/20/21
to puppe...@googlegroups.com
Nick Walker commented on Bug FACT-2918

Kenneth Pepiton thanks for the response.  It wasn't clear from the description that this used to work and it is a regression.  During triage we thought it never worked in Puppet.

I was able to reproduce that it worked in PE 2018.1.10 and does not work in PE 2019.8.4.  

[root@master-masterbranch-centos ~]# puppet --version
6.20.0
[root@master-masterbranch-centos ~]# cat /opt/puppetlabs/server/pe_build
2019.8.5-rc2-160-g4af732b
[root@master-masterbranch-centos ~]# FACTER_test_fact=blah puppet facts show | grep test
    "test_fact": "blah",
[root@master-masterbranch-centos ~]# mkdir /etc/puppetlabs/facter
[root@master-masterbranch-centos ~]# mkdir /etc/puppetlabs/facter/facts.d
[root@master-masterbranch-centos ~]# vim /etc/puppetlabs/facter/facts.d/test_fact.txt
[root@master-masterbranch-centos ~]# FACTER_test_fact=blah puppet facts show | grep test
    "test_fact": "foo",
[root@master-masterbranch-centos ~]# cat /etc/puppetlabs/facter/facts.d/test_fact.txt
test_fact=foo 

[root@master2018110-centos ~]# FACTER_test_fact=blah puppet facts show | grep test
    "test_fact": "blah",
[root@master2018110-centos ~]# puppet --version
5.5.23
[root@master2018110-centos ~]# cat /opt/puppetlabs/server/pe_build
2018.1.19-rc1-64-g1a7164a
 
[root@master2018110-centos ~]# cat /etc/puppetlabs/facter/facts.d/test_fact.txt
test_fact=foo 

We'll take a look at it.  

 

 

 

 

Mihai Buzgau (Jira)

unread,
Jan 27, 2021, 4:09:04 AM1/27/21
to puppe...@googlegroups.com

Dorin Pleava (Jira)

unread,
Jan 28, 2021, 2:57:04 AM1/28/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 28, 2021, 5:59:03 PM1/28/21
to puppe...@googlegroups.com

Isaiah Frantz (Jira)

unread,
Jan 28, 2021, 8:03:03 PM1/28/21
to puppe...@googlegroups.com

Nate McCurdy (Jira)

unread,
Jan 28, 2021, 8:06:04 PM1/28/21
to puppe...@googlegroups.com
Nate McCurdy commented on Bug FACT-2918

+1 to getting this fixed. Glad to see it's being triaged now.

It's a common workflow where I am to allow unprivileged users to run Puppet and set FACTER_ environment variables to toggle feature flags that we've built in to our code. As the users are unprivileged, they aren't able to write files to disk to modify an external fact. but they do have the rights to set an ENV variable for a one-off Puppet run.

This bug breaks that workflow.

Also of note, there's a test for this exact behavior in Facter so it's definitely meant to be working: https://github.com/puppetlabs/facter/blob/4.0.49/acceptance/tests/external_facts/env_var_overrides_external_fact.rb#L35-L42

How is that test passing? ...I guess it works when using Facter directory, but not when run through puppet facts.

Mihai Buzgau (Jira)

unread,
Feb 3, 2021, 4:43:03 AM2/3/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
 
Change By: Mihai Buzgau
Sprint: NW - 2021-02-03 , NW - 2021-02-17

Mihai Buzgau (Jira)

unread,
Feb 3, 2021, 7:32:04 AM2/3/21
to puppe...@googlegroups.com

Dorin Pleava (Jira)

unread,
Feb 3, 2021, 8:02:04 AM2/3/21
to puppe...@googlegroups.com
Dorin Pleava updated an issue
Change By: Dorin Pleava
Release Notes: Bug Fix
Release Notes Summary: When running puppet facts, environment facts were overwritten
by external facts.
Now the flow was set to default facts -> external facts -> environment facts

Claire Cadman (Jira)

unread,
Feb 5, 2021, 4:28:04 AM2/5/21
to puppe...@googlegroups.com
Claire Cadman updated an issue
Change By: Claire Cadman
Labels: doc_reviewed jira_escalated

Gheorghe Popescu (Jira)

unread,
Feb 5, 2021, 7:25:04 AM2/5/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages