]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Check if file exists before loading with loadyaml. If not, return nil
authorAngel L. Mateo <amateo@um.es>
Tue, 2 Sep 2014 09:35:42 +0000 (11:35 +0200)
committerAngel L. Mateo <amateo@um.es>
Tue, 2 Sep 2014 09:35:42 +0000 (11:35 +0200)
lib/puppet/parser/functions/loadyaml.rb

index 10c400501be487cf14221fdab40ee17ddb681307..ca655f6ea8cdf0d1488abec30420c4e9057890fa 100644 (file)
@@ -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