From 13ae8c035d6359717b90d074ca1ced88aad33bcb Mon Sep 17 00:00:00 2001 From: Barrow Kwan Date: Tue, 24 Jan 2017 20:44:01 -0800 Subject: [PATCH] services hash to yaml generate garbage to_yaml has generated garbage and make the newrelic plugin configuration completely invalid. The fix is to convert Chef's Hash to ruby hash , then JSON then to yaml. Without the JSON part still causing garbage in the configuration. --- providers/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/default.rb b/providers/default.rb index f4ac1fc..b6f6900 100644 --- a/providers/default.rb +++ b/providers/default.rb @@ -46,7 +46,7 @@ def generate_config services = { '#services' => new_resource.services } - services_yml = services.to_yaml(:indentation => 2).gsub(/(! )?['"]#services['"]:/, '#services:').gsub('---', '').gsub(%r{!(ruby\/|map|seq)[a-zA-Z:]*}, '') + services_yml = JSON.parse(services.to_hash.dup.to_json).to_yaml(:indentation => 2).gsub(/(! )?['"]#services['"]:/, '#services:').gsub('---', '').gsub(%r{!(ruby\/|map|seq)[a-zA-Z:]*}, '') # service restart service 'restart-newrelic-plugin-agent' do