summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/loadyaml.rb
diff options
context:
space:
mode:
authorAngel L. Mateo <amateo@um.es>2014-09-02 11:35:42 +0200
committerAngel L. Mateo <amateo@um.es>2014-09-02 11:35:42 +0200
commitb9560df899fdea34ac69692ef2447ffdd2d3365a (patch)
treeee0c5440a8bd7bfdf7028a5c9c53300f772af616 /lib/puppet/parser/functions/loadyaml.rb
parent9e8127bb64421f8476c32ba971a375c9c82fd7f0 (diff)
Check if file exists before loading with loadyaml. If not, return nil
Diffstat (limited to 'lib/puppet/parser/functions/loadyaml.rb')
-rw-r--r--lib/puppet/parser/functions/loadyaml.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/loadyaml.rb b/lib/puppet/parser/functions/loadyaml.rb
index 10c4005..ca655f6 100644
--- a/lib/puppet/parser/functions/loadyaml.rb
+++ b/lib/puppet/parser/functions/loadyaml.rb
@@ -13,7 +13,12 @@ module Puppet::Parser::Functions
raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
end
- YAML.load_file(args[0])
+ if File.exists?(args[0]) then
+ YAML.load_file(args[0])
+ else
+ warning("Can't load " + args[0] + ". File does not exist!")
+ nil
+ end
end