From 5131f59e352187f3e7db45673e13beffba497795 Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Thu, 7 Aug 2014 11:05:06 +0100 Subject: [PATCH] Fix template so it generates valid JSON --- templates/etc/sensu/uchiwa.json.erb | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/templates/etc/sensu/uchiwa.json.erb b/templates/etc/sensu/uchiwa.json.erb index fc4643f..b8d5717 100755 --- a/templates/etc/sensu/uchiwa.json.erb +++ b/templates/etc/sensu/uchiwa.json.erb @@ -1,24 +1,24 @@ -module.exports = { - sensu: [ - <%- scope.lookupvar("uchiwa::apis").each do | name, api | %> +{ + "sensu": [ +<% scope.lookupvar('uchiwa::apis').each_with_index do |(name,api),index| -%> { - name: '<%= name %>', - host: '<%= api['host'] %>', - ssl: <%= api['ssl'] %>, - port: <%= api['port'] %>, - user: '<%= api['user'] %>', - pass: '<%= api['pass'] %>', - path: '<%= api['path'] %>', - timeout: <%= api['timeout'] %> - }, - <%- end %> + "name": "<%= name %>", + "host": "<%= api['host'] %>", + "port": <%= api['port'] || 4567 %>, + "ssl": <%= api['ssl'] || false %>, + "user": "<%= api['user'] %>", + "pass": "<%= api['pass'] %>", + "path": "<%= api['path'] %>", + "timeout": <%= api['timeout'] || 5000 %> + }<%= ',' if index < scope.lookupvar('uchiwa::apis').length - 1 %> +<% end -%> ], - uchiwa: { - host: '<%= scope.lookupvar("uchiwa::host") %>', - port: <%= scope.lookupvar('uchiwa::port') %>, - user: '<%= scope.lookupvar("uchiwa::user") %>', - pass: '<%= scope.lookupvar("uchiwa::pass") %>', - stats: <%= scope.lookupvar('uchiwa::stats') %>, - refresh: <%= scope.lookupvar('uchiwa::refresh') %> + "uchiwa": { + "host": "<%= scope.lookupvar('uchiwa::host') %>", + "port": <%= scope.lookupvar('uchiwa::port') %>, + "user": "<%= scope.lookupvar('uchiwa::user') %>", + "pass": "<%= scope.lookupvar('uchiwa::pass') %>", + "stats": <%= scope.lookupvar('uchiwa::stats') %>, + "refresh": <%= scope.lookupvar('uchiwa::refresh') %> } -} \ No newline at end of file +}