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

0 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Henry Wang (Jira)

ungelesen,
14.01.2021, 02:28:0414.01.21
an 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)

ungelesen,
14.01.2021, 02:30:0414.01.21
an 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)

ungelesen,
14.01.2021, 02:31:0414.01.21
an puppe...@googlegroups.com

zendesk.jira (Jira)

ungelesen,
14.01.2021, 02:31:0514.01.21
an puppe...@googlegroups.com
zendesk.jira updated an issue
Change By: zendesk.jira
Zendesk Ticket Count: 1
Zendesk Ticket IDs: 42719

Mihai Buzgau (Jira)

ungelesen,
19.01.2021, 06:03:0419.01.21
an puppe...@googlegroups.com

Nick Walker (Jira)

ungelesen,
19.01.2021, 10:48:0419.01.21
an 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)

ungelesen,
19.01.2021, 14:44:0419.01.21
an 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)

ungelesen,
20.01.2021, 13:26:0320.01.21
an 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)

ungelesen,
27.01.2021, 04:09:0427.01.21
an puppe...@googlegroups.com

Dorin Pleava (Jira)

ungelesen,
28.01.2021, 02:57:0428.01.21
an puppe...@googlegroups.com

Josh Cooper (Jira)

ungelesen,
28.01.2021, 17:59:0328.01.21
an puppe...@googlegroups.com

Isaiah Frantz (Jira)

ungelesen,
28.01.2021, 20:03:0328.01.21
an puppe...@googlegroups.com

Nate McCurdy (Jira)

ungelesen,
28.01.2021, 20:06:0428.01.21
an 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)

ungelesen,
03.02.2021, 04:43:0303.02.21
an puppe...@googlegroups.com
Mihai Buzgau updated an issue
 
Change By: Mihai Buzgau
Sprint: NW - 2021-02-03 , NW - 2021-02-17

Mihai Buzgau (Jira)

ungelesen,
03.02.2021, 07:32:0403.02.21
an puppe...@googlegroups.com

Dorin Pleava (Jira)

ungelesen,
03.02.2021, 08:02:0403.02.21
an 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)

ungelesen,
05.02.2021, 04:28:0405.02.21
an puppe...@googlegroups.com
Claire Cadman updated an issue
Change By: Claire Cadman
Labels: doc_reviewed jira_escalated

Gheorghe Popescu (Jira)

ungelesen,
05.02.2021, 07:25:0405.02.21
an puppe...@googlegroups.com
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten