On Mar 2, 2010, at 4:58 AM, IgNoTo wrote:
Hello! I have a problem that is safer than syntax but no clear end in
view. The settings I use in puppet is somewhat "peculiar" because of
my needs.
The theory is that customers have a number of files in the manner and
mode configured, rather than the server that centralizes all this
information through the facters.
Now my problem is I created a file "exceptions", which contains the
absolute path of the file that should not control puppet.
Then I discuss the configuration:
FACT:
--------------------------------------------------
--------------------------
Facter.add("get_file") do
setcode do
%x{/bin/cat /etc/puppet/exception/files.txt}.chomp
end
end
--------------------------------------------------
--------------------------
FUNCTION: (This function is responsible for comparing strings and
return the result to the variable):
module Puppet::Parser::Functions
newfunction(:compara_cadenas, :type => :rvalue) do |args|
cadena=lookupvar('get_file')
array=cadena.split("\n")
result=noenc
array.each do |fichero|
if fichero == args[0]
result=enc
break
end
end
return result
end
end
-------------------------------------------------- ----------------
CLASS custom_functions.pp
class custom_functions {
define superfile ( $owner = root, $group = root, $mode = 644, $source,
$backup = false, $service) {
$temp = compara_cadenas("$name")
if ( $temp == noenc ) {
file { "$name":
mode => $mode,
owner => $owner,
group => $group,
backup => $backup,
source => "puppet:///files/$service/$source"
}
}
}
}
--------------------------------------------------
-------------------------
Well, if anyone can help me I would appreciate forever because I've
tried thousands of different ways and I did not succeed.
Sorry for the slow response here.
So you want to be able to have a client-side override on whether a
given file is managed by Puppet, right? That's basically what you're
saying?
Your code looks like it should basically work, so it's probably just
down to details. E.g., you should probably not use 'return' in the
'newfunction' declaration, because of some weird ruby behaviours.
You should probably also try true/false, rather than enc and noenc.
--
Due to circumstances beyond your control, you are master of your fate
and captain of your soul.
---------------------------------------------------------------------
Luke Kanies -|- http://reductivelabs.com -|- +1(615)594-8199
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.