My custom function looks like this : module Puppet::Parser::Functions newfunction(:pattern_in_file, :type => :rvalue) do |args| filename = args[0] pattern = args[1] value = false File.open(filename) do |f| f.each_line do |line| return true if line.match(pattern) end end false end end
ruby -rpuppet and irb tests to see if the function is seen by puppet end successfully without any error. Inside the manifests callings pattern_in_file('/etc/fstab', '/usr') don't complain or print anything, If I use : $getval = pattern_in_file('/etc/fstab', '/usr') It complains the following : Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Function 'pattern_in_file' does not return a value at /etc/puppet/modules/mname/manifests/datavers.pp:3 on node node_name Any suggestion why the return doesn't work ? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/q0SwlvmGVkcJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.