example42 / puppi

Puppet module to manage applications deployments and servers local management
http://www.example42.com
Other
142 stars 84 forks source link

[Puppet4] hiera() has been converted to 4x API #123

Closed ball-hayden closed 8 years ago

ball-hayden commented 9 years ago

With puppet 4, I'm getting the following error when using the 'example42/resolver' module:

Error: Evaluation Error: Error while evaluating a Function Call, hiera() has been converted to 4x API at /tmp/vagrant-puppet/modules-8deee6b1dbb6b30925b3305d7ee02e5c/resolver/manifests/init.pp:128:26

Line 128 reads as follows:

$dns_domain          = params_lookup( 'dns_domain' , 'global' )

which suggests the error is in params_lookup.

I assume this is being caused by the function_hiera, although I can't find any documentation to suggest what should be used instead.

alvagante commented 9 years ago

Uhm, have definitively to double check this

tstibbs commented 9 years ago

I'm also having the same problem running the example42/jboss module.

The various hiera functions seemed to change in this commit and again here.

Looks like the main issue is just that the package that the function is in has changed - but I don't have the ruby skills to work out what it should look like instead.

I'll include the back trace in case it helps:

Error: Evaluation Error: Error while evaluating a Function Call, hiera() has been converted to 4x API at /etc/puppetlabs/code/environments/production/modules/jboss/manifests/init.pp:278:26 on node mynode
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions/fail.rb:3:in `block in <top (required)>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:162:in `block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:155:in `block in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/scope.rb:793:in `method_missing'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions/hiera.rb:30:in `block in <module:Functions>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:162:in `block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:155:in `block in newfunction'
/etc/puppetlabs/code/environments/production/modules/puppi/lib/puppet/parser/functions/params_lookup.rb:42:in `block in <module:Functions>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:162:in `block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:155:in `block in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/runtime3_support.rb:248:in `call_function'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:810:in `call_function_with_block'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:790:in `eval_CallNamedFunctionExpression'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:67:in `visit_this_1'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:70:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/parser/evaluating_parser.rb:55:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast/pops_bridge.rb:27:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast.rb:31:in `safeevaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:476:in `block in set_default_parameters'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:470:in `each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:470:in `collect'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:470:in `set_default_parameters'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/type.rb:275:in `set_resource_parameters'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/type.rb:104:in `evaluate_code'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:79:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:216:in `each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:216:in `evaluate_classes'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions/include.rb:33:in `block in <top (required)>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:162:in `block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:155:in `block in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/functions/function.rb:103:in `internal_call_function'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/functions/function.rb:57:in `call_function'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/hiera_include.rb:15:in `post_lookup'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/puppet_function.rb:41:in `hiera'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/functions/dispatch.rb:45:in `invoke'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/functions/dispatcher.rb:35:in `dispatch'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/functions/function.rb:44:in `call'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/runtime3_support.rb:239:in `call_function'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:810:in `call_function_with_block'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:790:in `eval_CallNamedFunctionExpression'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:46:in `block in visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in `each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in `visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:69:in `visit_this_1'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:70:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:614:in `eval_Program'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:46:in `block in visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in `each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in `visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:69:in `visit_this_1'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:70:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/parser/evaluating_parser.rb:55:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast/pops_bridge.rb:96:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast.rb:31:in `safeevaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/type.rb:118:in `evaluate_code'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:79:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:405:in `evaluate_main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:127:in `block (2 levels) in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:127:in `block in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:223:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:117:in `compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:34:in `compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:93:in `block (2 levels) in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:91:in `block in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:129:in `block in benchmark'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:128:in `benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:90:in `compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:50:in `find'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:194:in `find'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:217:in `block in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:64:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:223:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:193:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:154:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:438:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:124:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
alvagante commented 9 years ago

Can you test if this works on Puppet 4? https://github.com/example42/puppi/tree/4xcompat

(won't work on Puppet 3, just to validate if it's enough what has been done there)

tstibbs commented 9 years ago

Thanks for that (and for the super-quick turnaround), I now get a different error:

Error: Evaluation Error: Error while evaluating a Function Call, undefined method `function' for Puppet::Functions:Module at /etc/puppetlabs/code/environments/production/modules/jboss/manifests/init.pp:278:26 on node mynode
/etc/puppetlabs/code/environments/production/modules/puppi/lib/puppet/parser/functions/params_lookup.rb:41:in `block in <module:Functions>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:162:in `block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in `profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:155:in `block in newfunction'

Looking at this suggests to me that it should now be in a package something like Hiera::PuppetFunction, but my (barely existent) ruby skills aren't good enough to work out what the correct call should be, I've tried Hiera::PuppetFunction.function('hiera') and similar but I haven't managed to work it out.

Tested on puppet open source 4.0.0.

alvagante commented 9 years ago

Made another blind attempt (can't check this now directly), please pull from 4xcompat branch and let me know. If this patch works, compatibility is dropped for Puppet 2.x without hiera, but both Puppet 3.x and Puppet 4.x should work.

tstibbs commented 9 years ago

Getting rid of the if gets rid of the error relating to that, so now we're back to the original error, which was that function_hiera() calls the old hiera function.

optize commented 9 years ago

I'm also getting the same error for example42/mysql. Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, hiera() has been converted to 4x API at /etc/puppetlabs/code/environments/production/modules/mysql/manifests/init.pp:225:26

alvagante commented 9 years ago

I've started to work on a 4x version of params_lookup, you can see it here: https://github.com/example42/puppi/blob/4xcompat/lib/puppet/functions/params_lookup.rb it's still not 100% working :

Jmeyering commented 9 years ago

:+1: For this issue being addressed. This is a major killer for upgrading to 4.0

alvagante commented 9 years ago

Yes I know and agree. Quick help in getting the module name here would be welcomed https://github.com/example42/puppi/blob/4xcompat/lib/puppet/functions/params_lookup.rb#L30

alvagante commented 8 years ago

An update, I fixed some lookups here https://github.com/example42/puppi/commit/e42aefaf328881c42ab32785966ff9da76e64d46 but the most core part is still missing, I need a way to get the module_name from within a Puppet4 function, and even if this looks trivial, I haven't found any. Post a question also here: https://groups.google.com/forum/#!topic/puppet-dev/I_DXTAHQEjE

alvagante commented 8 years ago

Asking to puppet-dev has had immediate results. In https://github.com/example42/puppi/tree/4xcompat there's a working Puppet 4 params_lookup. I still have an issue to fix with warning messages but the lookups seem to work. Anyway available for further tests before I merge to master?

alvagante commented 8 years ago

params_lookup works on Puppet 4 now. It's not supported yet the legacy usage of params_lookup outside the main module class (it was never intended to be used in that way, but some people did)

wooziethe commented 8 years ago

Hello Alvagante,

I've tired your workaround(https://github.com/example42/puppi/blob/master/lib/puppet/functions/params_lookup.rb), but "hiera() has been converted to 4x API" still there.

Exact error is:

Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, hiera() has been converted to 4x API at /etc/puppetlabs/code/environments/production/modules/puppetdashboard/manifests/init.pp:261:33 on node puppet-test Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

Is this problem solved or its still in progress? Or Im missing something?

BR, Alex

wooziethe commented 8 years ago

I have feeling, that the old params_lookup.rb is cached somewhere. I have totally removed it from the system, but it still tries to call hiera() starting from the $db_host = params_lookup( 'db_host' ). Reinstaleld the module and dependencies, recompiled catalog and tried again without doing first run with original params_lookup.rb, the deleted the original params_lookup.rb script.

Still same error...

Regards, Alex

alvagante commented 8 years ago

Did you run puppet on the master? Functions are evaluated on the master at catalog compile time. (Eventually a restart of the puppet master service might be useful)

wooziethe commented 8 years ago

Yes, I have master, puppetdb and agent on the same machine. I'll restart the master tomorrow. Do you have an idea where init.pp goes to execute params_lookup.rb, if I have totally (in my opinion) deleted params_lookup.rb from the system?

Regards, Alex

wooziethe commented 8 years ago

I removed module and dependencies, compiled catalog on master without dashboard module - OK so far... Then I restarted puppet master and puppetdb, compiled catalog again - still OK. Installed module again and without compiling replaced content of the params_lookup.rb file with: https://github.com/example42/puppi/blob/master/lib/puppet/functions/params_lookup.rb .

After running puppet agent -t it shows new error:

Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Unknown function: 'params_lookup'. at /etc/puppetlabs/code/environments/production/modules/puppetdashboard/manifests/init.pp:261:33 on node puppet-test Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

So function is not recognized. Function is synced and after compilation apears under: /opt/puppetlabs/puppet/cache/lib/puppet/parser/functions/params_lookup.rb

Regards, Alex

alvagante commented 8 years ago

What do you mean by: "replaced content of the params_lookup.rb" You are not supposed to do anything manually. It's correct to have params_lookup in two locations: lib/puppet/parser/functions for Puppet3 (Puppet 4 uses it only if it doesn't find an homonymous function in lib/puppet/functions)
lib/puppet/functions for Puppet4 (will be ignored in Puppet3)

So procedure should be:

If you still have problems , please send me the output of facter for both master and clients.

wooziethe commented 8 years ago

Ok, seems that solvses it. But now Ive got new error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Failed to parse template puppetdashboard/default-workers.init-ubuntu: Filepath: /etc/puppetlabs/code/environments/production/modules/puppetdashboard/templates/default-workers.init-ubuntu Line: 10 Detail: undefined local variable or method `processorcount' for #Puppet::Parser::TemplateWrapper:0x253ef2a at /etc/puppetlabs/code/environments/production/modules/puppetdashboard/manifests/init.pp:478:18 on node puppet-test Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

It refers to: content => template('puppetdashboard/default-workers.init-ubuntu'), in init.pp

and NUM_DELAYED_JOB_WORKERS=<%= processorcount %> in default-workers.init-ubuntu'

Seems that it cant get processorcount.

Regards, Alex

wooziethe commented 8 years ago

OK, this one solved - "@" was missing: so correct is NUM_DELAYED_JOB_WORKERS=<%= @processorcount %>

New challange:

Error: Failed to apply catalog: Parameter source failed on File[mysql.dir]: Cannot use relative URLs '' at /etc/puppetlabs/code/environments/production/modules/mysql/manifests/init.pp:427

The whole mysql configuration directory can be recursively overriden

if $mysql::source_dir { file { 'mysql.dir': .............. } }

ball-hayden commented 8 years ago

@wooziethe - with all due respect, it doesn't look like the issues you are now having are related to puppi.

@alvagante apologies for going silent on this - I've been really busy recently. I'll try and have a look this evening to check this fixes my issues.

wooziethe commented 8 years ago

ball-hayden, the last issue is related to puppi, because file 'mysql.dir': deals with params_lookup function, which does not return expected values.

$config_dir = params_lookup( 'config_dir' ), $source_dir = params_lookup( 'source_dir' ),

if $mysql::source_dir {
file { 'mysql.dir':
  ensure  => directory,
  path    => $mysql::config_dir,
  require => Package['mysql'],
  notify  => $mysql::manage_service_autorestart,
  source  => $mysql::source_dir,
  recurse => true,
  purge   => $mysql::bool_source_dir_purge,
  replace => $mysql::manage_file_replace,
  audit   => $mysql::manage_audit,
}

}

Regards, Alex

alvagante commented 8 years ago

@wooziethe try to set this line to false instead of '': https://github.com/example42/puppet-mysql/blob/master/manifests/params.pp#L106 it should be an issue related to the fact that in Puppet 4 empty strings are evaluated as true. If it works, please submit a PR (a similar fix is needed in many other modules)

wooziethe commented 8 years ago

Yes, this helped, but mysql installation went wrong. But this is another story... Same change must be made under puppetdashboard/manifests/init.pp

tux-o-matic commented 8 years ago

When can we expect a new release on Forge with the v4 compatibility?

alvagante commented 8 years ago

Check for Version 2.1.12 on the Forge. ty

mklette commented 8 years ago

dear @alvagante , sorry to misuse this thread but I wonder why the puppet4 params_lookup doesn't support defining defaults anymore. Is there a special reason? Thanks Mathias

alvagante commented 8 years ago

@mklette possibly some left over, can you be more precise about defaults support?

mklette commented 8 years ago

sorry, I was wrong: I looked at the customised version we use which has been extended with some 'interesting' mechanisms to allow a signature of params_lookup( [, |'global' [, 'global']]) This way we could define a default result directly when calling params_lookup. This appeared handy first but turns out to allow for too many different sources of parameter values. We'll return to your original version instead. Thanks anyways!

djonnala commented 7 years ago

I still have issue with puppet 4.8.1

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, hiera() can only be called using the 4.x function API. See Scope#call_function at /etc/puppetlabs/puppet/tenants/tetcoreweb_tenant/modules/splunk/manifests/init.pp:197:26

alvagante commented 7 years ago

Please provide some context. Eventually open a new ticket.

djonnala commented 7 years ago

while using splunk module "example42/splunk". I get the following error Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, hiera() can only be called using the 4.x function API. See Scope#call_function at /etc/puppetlabs/puppet/tenants/tetcoreweb_tenant/modules/splunk/manifests/init.pp:197:26

It is erroring out at params_lookup function as it is not available in splunk module. I manually copied it from puppi module into splunk module and it seems to work.

alvagante commented 7 years ago

yes params_lookup function is provided by puppi module, you should have the latest version of puppi in your modulepath in order to use the splunk module (and most of the other (now old) modules of example42)

cdenneen commented 7 years ago

@alvagante Latest version of puppi with latest tagged release of monit (v2.0.18) and getting these same errors. Has monit been updated?

alvagante commented 7 years ago

@cdenneen The monit module is no more actively maintained but the error seems actually related to and old version of params_lookup used somewhere. Please try to look in your module path if you have older versions of params_lookup, the one in the current puppi module. (which actually seems the one you are using) should work. If not, please ping me back.

Note that params_lookup function which works with Puppet4 is: lib/puppet/functions/params_lookup.rb the one for older Puppet function API is: lib/puppet/parser/functions/params_lookup.rb

cdenneen commented 7 years ago

This was from rspec testing run. So latest was downloaded to fixtures during run.

On Tue, Mar 14, 2017 at 7:30 AM Alessandro Franceschi < notifications@github.com> wrote:

@cdenneen https://github.com/cdenneen The monit module is no more actively maintained but the error seems actually related to and old version of params_lookup used somewhere. Please try to look in your module path if you have older versions of params_lookup, the one in the current puppi module. (which actually seems the one you are using) should work. If not, please ping me back.

Note that params_lookup function which works with Puppet4 is: lib/puppet/functions/params_lookup.rb the one for older Puppet function API is: lib/puppet/parser/functions/params_lookup.rb

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/example42/puppi/issues/123#issuecomment-286394465, or mute the thread https://github.com/notifications/unsubscribe-auth/AAr84SEcE6-0eaSTwstG3iN3tzAXLIjUks5rlnpSgaJpZM4EPVz- .

FrankVanDamme commented 7 years ago

The one from the older Puppet function API is used, however. I have the same problem and I can make the Puppet agent run by replacing the lines inside if Puppet::Parser::Functions.function('hiera') in lib/puppet/parser/functions/params_lookup.rb by

      value = call_function('hiera', [ "#{module_name}_#{var_name}" , ''])
      return value if (value != '')

      value = call_function('hiera', ["#{var_name}", '']) if arguments[1] == 'global' 
      return value if (not value.nil?) && (value != :undefined) && (value != '') 

(it works far from perfectly because module_name refers to the topmost module - which is called "profile" where I currently use it even if the params_lookup call is inside a class in another module)

Poil commented 7 years ago

+1 @FrankVanDamme