From 4b502342ad318d23d37870b4defda8bf48849512 Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Wed, 20 Jan 2016 15:39:24 -0800 Subject: [PATCH] Fix generated config file on Chef 11.14. The config file generated looks like this on Chef 11.14 and remote_syslog2 can't understand it: files: !ruby/array:Chef::Node::ImmutableArray - /foo/bar exclude_files: !ruby/array:Chef::Node::ImmutableArray [] exclude_patterns: !ruby/array:Chef::Node::ImmutableArray [] hostname: foo.com destination: !ruby/hash:Chef::Node::ImmutableMash host: bar.com port: 12345 protocol: tls --- recipes/configure.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes/configure.rb b/recipes/configure.rb index 045dee0..ec21f4a 100644 --- a/recipes/configure.rb +++ b/recipes/configure.rb @@ -1,5 +1,9 @@ file node['remote_syslog2']['config_file'] do - content node['remote_syslog2']['config'].to_hash.to_yaml + # Using JSON.parse(x.to_json) to convert Chef::Node::ImmutableArray and + # Chef::Node::ImmutableMash to plain Ruby array and hash. + # https://tickets.opscode.com/browse/CHEF-3953 + content JSON.parse(node['remote_syslog2']['config'].to_json).to_yaml + mode '0644' notifies :restart, 'service[remote_syslog2]', :delayed end \ No newline at end of file