Skip to content

Commit 1d5757f

Browse files
committed
(Docs)(DOCUMENT-1429) Update find_file() comment in files.rb
Testing confirms that the `find_file()` function may indeed be used to verify the existence of a file specified by absolute path, with the caveat that this check appears to be performed prior to any resource changes made by the same code. The following code, when run via "puppet apply", accurately reports the existence or non-existence of a test file *before* deleting that file. ``` $testpath = '/tmp/testfile' file { $testpath: ensure => absent } if find_file($testpath) { notify { "$testpath exists.": } } else { notify { "$testpath does not exist.": } } ```
1 parent fc70183 commit 1d5757f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/puppet/parser/files.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ def find_manifests_in_modules(pattern, environment)
2929
# * modulename/filename selector: a file is found in the file directory
3030
# of the named module.
3131
#
32-
# In the second case a nil is returned if there isn't a file found. In the
33-
# first case (absolute path), there is no existence check done and so the
34-
# path will be returned even if there isn't a file available.
32+
# The check for file existence is performed on the node compiling the
33+
# manifest. A node running "puppet apply" compiles its own manifest, but
34+
# a node running "puppet agent" depends on the configured puppetserver
35+
# for compiling. In either case, a nil is returned if no file is found.
3536
#
3637
# @param template [String] the file selector
3738
# @param environment [Puppet::Node::Environment] the environment in which to search

0 commit comments

Comments
 (0)