I am creating a configuration file for one of our built-in applications. This is essentially a json file. I have a lot of problems getting a puppet / ruby โโ1.8 to output the / json hash each time.
I am currently using
<%= require "json"; JSON.pretty_generate data %>
But when releasing human-readable content, it does not guarantee the same order every time. This means that the puppet often sends change notifications for the same data.
I also tried
<%= require "json"; JSON.pretty_generate Hash[*data.sort.flatten] %>
which will generate the same data / order every time. The problem occurs when the data has a nested array.
data => { beanstalkd => [ "server1", ] }
becomes
"beanstalkd": "server1",
instead
"beanstalkd": ["server1"],
I struggled with this for several days and now, so I need help
Gavin mogan
source share