I'm using the mongodb3 cookbook (took from chef supermarket) in my environment. When ever we pass input for mongos template like [10.10.0.10,127.0.0.1] , the output file is created with improper syntax:
PFB out put -
net:
port: 27017
bindIp: ! '[10.10.0.10,127.0.0.1]'
There's a !
and ''
around the square brackets instead of only [10.10.0.10,127.0.0.1]
I am using below function to convert.
module Mongodb3Helper
def mongodb_config(config)
config.to_hash.compact.to_yaml
end
end
class Hash
def compact
inject({}) do |new_hash, (k, v)|
if v.is_a?(Hash)
v = v.compact
new_hash[k] = v unless v.empty?
else
new_hash[k] = v unless v.nil?
end
new_hash
end
end
end