Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ball-hayden opened this issue May 4, 2015 · 39 comments
Closed

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

ball-hayden opened this issue May 4, 2015 · 39 comments

Comments

@ball-hayden
Copy link

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
Copy link
Member

Uhm, have definitively to double check this

@tstibbs
Copy link

tstibbs commented May 13, 2015

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
Copy link
Member

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
Copy link

tstibbs commented May 13, 2015

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
Copy link
Member

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
Copy link

tstibbs commented May 13, 2015

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
Copy link

optize commented Jun 12, 2015

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
Copy link
Member

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
Copy link

👍 For this issue being addressed. This is a major killer for upgrading to 4.0

@alvagante
Copy link
Member

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
Copy link
Member

An update, I fixed some lookups here e42aefa
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
Copy link
Member

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 added a commit that referenced this issue Jul 21, 2015
Fix for #123 Puppet4 compatibility of params_lookup
@alvagante
Copy link
Member

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
Copy link

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
Copy link

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
Copy link
Member

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
Copy link

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
Copy link

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
Copy link
Member

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:

  • Place the new puppi in your puppetmaster's modulepath
  • Run puppet on the master to pluginsync and then restart the puppetmaster (not 100% sure it's needed but better to do that)
  • Run puppet on the clients

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

@wooziethe
Copy link

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
Copy link

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
Copy link
Author

@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
Copy link

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
Copy link
Member

@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
Copy link

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
Copy link

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

@alvagante
Copy link
Member

Check for Version 2.1.12 on the Forge.
ty

@mklette
Copy link

mklette commented Feb 24, 2016

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
Copy link
Member

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

@mklette
Copy link

mklette commented Feb 26, 2016

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
Copy link

djonnala commented Mar 8, 2017

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
Copy link
Member

Please provide some context. Eventually open a new ticket.

@djonnala
Copy link

djonnala commented Mar 8, 2017

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
Copy link
Member

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
Copy link

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

@alvagante
Copy link
Member

@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
Copy link

cdenneen commented Mar 14, 2017 via email

@FrankVanDamme
Copy link

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
Copy link
Contributor

Poil commented Apr 28, 2017

+1 @FrankVanDamme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests