[Puppet Users] custom function from .24.6 not working in 2.6 (from squeeze)

2011-05-19 Thread Bill Anderson
I'm in the process of upgrading an existing installation from .24.x to 2.6.

We seem to have a custom function that is throwing the error:
"err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
private method `gsub' called for # at 
/etc/puppet/manifests/classes/apache-php.pp:72"

Here is the function:
"""
# Checks if a file exists on the puppet maser
Puppet::Parser::Functions::newfunction(:bbcom_file_exists, :type => :rvalue,
:doc => "Checks if the given file exists on the puppet master.") do 
|vals|
ret = false

vals.each do |file|
# First convert our $puppet urls to local filesystems urls
# We do this to allow the caller to use the same urls array
# in other parts of the recipe.  
file = file.gsub("puppet:///appconf/", "/etc/cdir/config/")

# Now do the same for internal server files 
file = file.gsub("puppet:///files/", "/etc/puppet/files/")

unless file =~ /^#{File::SEPARATOR}/
raise Puppet::ParseError, "Files must be fully qualified"
end
if File.exists?(file)
ret = true
   break
end
end
ret
end
"""
The function is used as a conditional: given a list of files puppet may be 
managing, if any of them exist on the server, then do this other thing (so 
far it usually means "manage this other file too").

Personally I'd love to be able to remove it as it seems clunky to me; but 
failing that if someone can point out why it is failing in 2.6 and how to 
fix it I would greatly appreciate it. I'm not much of a Ruby guy so while  I 
understand _what_ the error is telling me, fixing it is a different story.

Cheers,
Bill

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
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.



[Puppet Users] Re: custom function from .24.6 not working in 2.6 (from squeeze)

2011-05-20 Thread Bill Anderson


On Friday, May 20, 2011 7:47:54 AM UTC-6, jcbollinger wrote:
>
>
>
>
> It looks like at least one function argument is being received as an 
> array instead of as a string.  It may be that 0.24.x was flattening 
> that array into a series of individual arguments, whereas 2.6.x does 
> not.  If that's the case, then you may be able to fix the problem by 
> changing 
>
> vals.each do |file| 
>
> to 
>
> vals.flatten.each do |file| 
>
> Alternatively, you may be able to approach the problem on the manifest 
> side by passing multiple arguments instead of an array. 
>

Thanks, that works. I'm still going to look for finding a better solution. I 
*quite* want to get upgraded. I suspect some of the "new to us" features 
will make this easier. If nothing else I'd rather see a boolean variable 
handle it. At least that is easily readable and discoverable.

Cheers,
Bill
 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
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.