Jira (PUP-10300) find_file function returns path even if absolute path does not exist

29 views
Skip to first unread message

Josh Cooper (JIRA)

unread,
Feb 19, 2020, 3:52:09 PM2/19/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Puppet / Bug PUP-10300
find_file function returns path even if absolute path does not exist
Change By: Josh Cooper
Summary: find_file function returns path even if absolute path does not exit exist
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Florian Faltermeier (JIRA)

unread,
Feb 20, 2020, 9:23:05 AM2/20/20
to puppe...@googlegroups.com
Florian Faltermeier commented on Bug PUP-10300
 
Re: find_file function returns path even if absolute path does not exist

Hello Josh,

I'm sure that the file doesn't exist.

Regards,

Florian

Josh Cooper (Jira)

unread,
Mar 13, 2020, 1:10:04 AM3/13/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10300

I can't reproduce:

[root@soft-shipboard ~]# rpm -qa | grep puppet
puppet-agent-6.14.0-1.el7.x86_64
puppet6-release-6.0.0-1.el7.noarch
puppetserver-6.9.1-1.el7.noarch

$file = find_file('/etc/testfile')
notify { "PUP-10300":
 message => "Path is $file"
}

When I run the agent, I get the expected value:

[root@soft-shipboard ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for soft-shipboard.delivery.puppetlabs.net
Info: Applying configuration version '1584076112'
Notice: Path is
Notice: /Stage[main]/Main/Notify[PUP-10300]/message: defined 'message' as 'Path is '
Notice: Applied catalog in 0.01 seconds

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

Florian Faltermeier (Jira)

unread,
Mar 30, 2020, 8:36:02 AM3/30/20
to puppe...@googlegroups.com

Hello Josh,

I'm still getting  a courious behaviour:

As an example:

$file_exists = find_file('/etc/testfile') # file does not exist on disk within this directory

unless $file_exists

{ # Puppet code, do something }

the unless statement wouldn't be executed. Or I am doing something wrong?

Florian

 

Cedric (Jira)

unread,
Oct 22, 2020, 5:44:04 AM10/22/20
to puppe...@googlegroups.com
Cedric commented on Bug PUP-10300

That would be my understanding. Florian Faltermeier did you find a solution?

I am having the same issue, it looks like the find_file is only checked at the agent first run.

using the following, /etc/testfile foes not exist

 $file = find_file('/etc/testfile')
 notify { "PUP-10300":
 message => "Path is $file"
 }

First run of the agent

/opt/puppetlabs/bin/puppet agent -t


Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales

Info: Loading facts
Info: Caching catalog for node-jenkins2
Info: Applying configuration version 'puppet6-production-93da0717e54'
Notice: Path is
Notice: /Stage[main]/Tanium::Config/NotifyPUP-10300/message: defined 'message' as 'Path is '
Notice: Applied catalog in 15.57 seconds

Second run of the agent

touch /etc/testfile && chmod 777 /etc/testfile && ll /etc/testfile
-rwxrwxrwx 1 root root 0 Oct 22 10:35 /etc/testfile*

/opt/puppetlabs/bin/puppet agent -t


Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales

Info: Loading facts
Info: Caching catalog for node-jenkins2
Info: Applying configuration version 'puppet6-production-93da0717e54'
Notice: Path is
Notice: /Stage[main]/Tanium::Config/NotifyPUP-10300/message: defined 'message' as 'Path is '
Notice: Applied catalog in 15.57 seconds

On the second run, the file existed, so I would have expected it to be in the notify.

If I do the reverse, using a '/etc/testfile2' already present, before the first run, and remove it before the second, same is happening, the notify will show the file even when it's not there anymore.

Running on ubuntu bionic, agent 6.19.0, server 6.13.0

Tks,
C/

Josh Cooper (Jira)

unread,
Oct 22, 2020, 1:10:03 PM10/22/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10300

find_file is a server-side function, so the check occurs during catalog compilation. If you want a client-side function, see the Deferred data type.

Josh Cooper (Jira)

unread,
Oct 27, 2020, 11:45:03 PM10/27/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10300

Florian Faltermeier find_file behaves as expected for me (looking for a file on the puppetserver at catalog compilation time. I’m going to close this for now. Please reopen with steps to reproduce if I’m missing something.

Reply all
Reply to author
Forward
0 new messages