Closed PierreR closed 9 years ago
This is correct, and I think this could be possible to support. I'll think about it.
Just pushed something ... does it help ?
It will return bogus answer for some functions though (like defined
) because we don't have access to the puppet state from withing the templates.
It does not work. It actually does not go into def method_missing(sname,*args,&block)
when the error occurs. If I add a puts
statement there, nothing with the prefix function_
gets printed (it just prints scope
or file
)
In case it helps here is the error:
ERROR: (puppet/foreman_testing) undefined method `function_bool2httpd' for #<Scope:0x007fd7a800bd38>
(erb):3:in `get_binding'
/usr/lib/ruby/2.2.0/erb.rb:863:in `eval'
/usr/lib/ruby/2.2.0/erb.rb:863:in `result'
Can you tell me how to reproduce your setup ? I suppose I need the apache module and your implementation of bool2httpd ?
I have just committed the implementation of the function.
I was wondering if the following change is not required too ? (it does not fix the problem though)
--- a/Puppet/Daemon.hs
+++ b/Puppet/Daemon.hs
@@ -77,12 +77,12 @@ initDaemon prefs = do
pfilecache <- newFileCache
let getStatements = parseFunction prefs pfilecache parserStats
intr <- startRubyInterpreter
- getTemplate <- initTemplateDaemon intr prefs templateStats
hquery <- case prefs ^. hieraPath of
Just p -> either error id <$> startHiera p
Nothing -> return dummyHiera
luacontainer <- initLuaMaster (T.pack (prefs ^. puppetPaths.modulesPath))
let myprefs = prefs & prefExtFuncs %~ HM.union luacontainer
+ getTemplate <- initTemplateDaemon intr myprefs templateStats
return (DaemonMethods (gCatalog myprefs getStatements getTemplate catalogStats hquery) parserStats catalogStats templateStats)
Oh perhaps it is !
I tried something significantly more complicated here. I hope this doesn't break anything ...
I am going further with it trying to test the new code as much as I can.
So far so good except that I have probably discovered another little bug.
puppetresources
cannot resolve 1 == -1
or anything with a minus such as x == -y
Here is the code and the error: https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/default_mods.pp#L16
ERROR: (puppet/foreman_testing) Don't know how to resolve this expression:
- (1) at # "./modules/apache/manifests/default_mods.pp" (line 16, column 9)
For all these years, this case was not handled ... this should be the case now.
Thanks for the quick fix.
There is also a kind of a "debug" statement left. I am not sure if it is on purpose.
> puppetresources -p . -o pgserver_testing --hiera ./tests/hiera.yaml --pdbfile ./tests/facts.yaml -n postgresql94
("versioncmp",[PString "9.4",PString "9.1"],Right (PString "1"))
package {
postgresql94: # "./modules/postgresql/manifests/client.pp" ( .....
woops ...
Fixed.
Looks good. Thanks for the fix !
In Puppet, functions defined in
modulename/lib/puppet/parser/functions/
can be used insideerb
templates by prefixing them byfunction_
.To support the
apache
puppetlabs module, I addbool2httpd
into our haskell modulePuppetlabs
.It still does not work and I am now under the impression that
prefExtfuncs
(including the one defined in lua files) won't be lookup inerb
templates. Is this correct ?If so, would it be hard to support this ?