jinja json template adds an extra comma breaking json structure

140 views
Skip to first unread message

David Neudorfer

unread,
Aug 13, 2014, 2:05:47 AM8/13/14
to ansible...@googlegroups.com
How can I stop the look inside the jinja template so when it gets the the last item it doesn't add a comma at the end breaking the json format. I can clearly the very last command on the 5th to last line is whats wrong but I can't come up with a solution to this problem. Thanks!

This is my jinja template:

{
   
"checks":
     
{
{% if elite_receipt_active_domains is defined %}
{% for check in elite_receipt_active_domains %}
   
"{{ check.domain }}-cert_check": {
     
"command": "/etc/sensu/plugins/check-https-cert.rb --url https://{{ check.domain }} --warning 30 --critical 10",
     
"handlers": [
       
{{ check.handlers | to_nice_json }}
     
],
     
"interval": {{ ssl_cert_check_interval }},
     
"standalone": true,
     
"subscribers": ["test"]
   
},
{% endfor %}
{% for check in elite_receipt_active_domains %}
   
"{{ check.domain }}-http_redirect_check": {
     
"command": "/etc/sensu/plugins/check-http.rb --url https://{{ check.domain }} -s false --response-code 301 --redirect-to https://{{ check.domain }} ",
     
"handlers": [
       
{{ check.handlers | to_nice_json }}
     
],
     
"interval": {{ http_redirect_checK_interval }},
     
"standalone": true
   
},
{% endfor %}
{% for check in elite_receipt_active_domains %}
   
"{{ check.domain }}-https_check": {
     
"command": "/etc/sensu/plugins/check-http.rb --url https://{{ check.domain }} -s true ",
     
"handlers": [
       
{{ check.handlers | to_nice_json }}
     
],
     
"interval": {{ http_check_interval }},
     
"standalone": true
   
},
{% endfor %}
{% endif %}
 
}
}


Reply all
Reply to author
Forward
0 new messages