I have json file which import as environment file to chef,
{
"mongodb": {
"replicaset": {
"nodes": [
"test-mongo1:27017",
"test-mongo2:27017"
]
}
}
}
I chef cookbook template added as below to build the mongo connection string,
"mongo": {
"url" : "mongodb://<% node['mongodb']['replicaset']['nodes'].each do |replica| -%>admin:123456@<%= replica %>/user_db1",
<% end %>
But output like below and not validating as JSON
"mongo": {
"url" : "mongodb://admin:123456@test-mongo1:27017/user_db1",
admin:123456@test-mongo2:27017/user_db1",
Expected Result:
"mongo": {
"url" : "mongodb://admin:123456@test-mongo1:27017/user_db1,admin:123456@test-mongo2:27017/user_db1",
Followed How to Run for each loop in template chef, But my ruby isn't the best because I'm just starting out with all of this stuff. Any help would be great, thanks.