summaryrefslogtreecommitdiffstats
path: root/roles/openshift_certificate_expiry/templates/save_json_results.j2
blob: 9b165f26c5fab7bb7d56476d2f9fa90f1b18d957 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "data": {
{% for host in play_hosts %}
{# Pretty print the check results for each host #}
    "{{host}}": {{ hostvars[host].check_results.check_results | to_nice_json(indent=6) }}{% if not loop.last %},
{% else %}

{% endif %}
{% endfor %}
  },
{# extract the nested warning/expired value from the hostvars object
using items in the playhosts list as a map. Wrap those results up into
a list and then add them all together #}
{%- set warned = play_hosts|map('extract', hostvars, ['check_results', 'summary', 'warning'])|list|sum %}
{%- set expired = play_hosts|map('extract', hostvars, ['check_results', 'summary', 'expired'])|list|sum %}
  "summary": {
    "warning": {{ warned }},
    "expired": {{ expired }}
  }
}