{ "certificates": [ {% set cert = {} %} {% for line in certbot_certificates %} {% if line.startswith(' Certificate Name:') %} {% if cert %} {{ cert | to_nice_json }},{% set cert = {} %} {% endif %} {% set cert = cert.copy() %} {% set cert['name'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Serial Number:') %} {% set cert = cert.copy() %} {% set cert['serial'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Key Type:') %} {% set cert = cert.copy() %} {% set cert['key_type'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Domains:') %} {% set cert = cert.copy() %} {% set cert['domains'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Expiry Date:') %} {% set cert = cert.copy() %} {% set cert['expiry'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Certificate Path:') %} {% set cert = cert.copy() %} {% set cert['cert_path'] = line.split(':', 1)[1].strip() %} {% elif line.startswith(' Private Key Path:') %} {% set cert = cert.copy() %} {% set cert['key_path'] = line.split(':', 1)[1].strip() %} {% endif %} {% if loop.last and cert %} {{ cert | to_nice_json }} {% endif %} {% endfor %} ] }