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

Legacy 3.x function #121

Open
AlessandroLorenzi opened this issue Feb 7, 2019 · 5 comments
Open

Legacy 3.x function #121

AlessandroLorenzi opened this issue Feb 7, 2019 · 5 comments

Comments

@AlessandroLorenzi
Copy link

AlessandroLorenzi commented Feb 7, 2019

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.2.0
  • Module version: 2.2.1

Output log

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Illegal method definition of method 'sorted_generate' on line 8' in legacy function. See https://puppet.com/docs/puppet/latest/functions_refactor_legacy.html for more information (file: /etc/puppetlabs/code/environments/production/modules/consul_template/manifests/config.pp, line: 17, column: 19) on node web2
@AlessandroLorenzi
Copy link
Author

AlessandroLorenzi commented Feb 7, 2019

Partial fix:

-module Puppet::Parser::Functions
-  newfunction(:consul_template_sorted_json, type: :rvalue, doc: <<-EOS
-This function takes unsorted hash and outputs JSON object making sure the keys are sorted.
-Optionally you can pass 2 additional parameters, pretty generate and indent length.
-
-*Examples:*
- [..snap..]
+Puppet::Functions.create_function(:consul_template_sorted_json) do
+  def consul_template_sorted_json(*args)
     unsorted_hash = args[0]      || {}
     pretty        = args[1]      || false
     indent_len    = args[2].to_i || 4
-
     return JSON.sorted_pretty_generate(unsorted_hash, indent_len) << "\n" if pretty
     JSON.sorted_generate(unsorted_hash)
   end

I have still this error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Illegal method definition of method 'sorted_generate' on line 8' in legacy function. See https://puppet.com/docs/puppet/latest/functions_refactor_legacy.html for more information (file: /etc/puppetlabs/code/environments/production/modules/consul_template/manifests/config.pp, line: 17, column: 19) on node web2

@regner
Copy link

regner commented Mar 22, 2019

Were you able to solve this?

@regner
Copy link

regner commented Mar 23, 2019

For anyone else running into this, someone else has already solved it in their fork (no PR from them yet): https://github.com/l-lotz/puppet-consul_template

@ydixken
Copy link

ydixken commented Apr 29, 2019

+1 for the PR

@findmyname666
Copy link

Hello guys, do you plan to fix/merge this in the near future ?

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

4 participants