Open AlessandroLorenzi opened 5 years ago
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
Were you able to solve this?
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
+1 for the PR
Hello guys, do you plan to fix/merge this in the near future ?
Affected Puppet, Ruby, OS and module versions/distributions
6.2.0
2.2.1
Output log