From 314da6ffb37c88ca424b927979bae3219251ed5b Mon Sep 17 00:00:00 2001 From: Tim Bielawa Date: Mon, 10 Oct 2016 10:54:53 -0700 Subject: Add JSON result CLI parsing notes to the README --- roles/openshift_certificate_expiry/README.md | 36 ++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'roles/openshift_certificate_expiry') diff --git a/roles/openshift_certificate_expiry/README.md b/roles/openshift_certificate_expiry/README.md index f296c905e..d44438332 100644 --- a/roles/openshift_certificate_expiry/README.md +++ b/roles/openshift_certificate_expiry/README.md @@ -50,7 +50,7 @@ Default behavior: ```yaml --- - name: Check cert expirys - hosts: all + hosts: nodes:masters:etcd become: yes gather_facts: no roles: @@ -62,7 +62,7 @@ Generate HTML and JSON artifacts in their default paths: ```yaml --- - name: Check cert expirys - hosts: all + hosts: nodes:masters:etcd become: yes gather_facts: no vars: @@ -78,7 +78,7 @@ the module out): ```yaml --- - name: Check cert expirys - hosts: all + hosts: nodes:masters:etcd become: yes gather_facts: no vars: @@ -93,7 +93,7 @@ the module out) and save the results as a JSON file: ```yaml --- - name: Check cert expirys - hosts: all + hosts: nodes:masters:etcd become: yes gather_facts: no vars: @@ -198,6 +198,34 @@ The example below is abbreviated to save space: } ``` +The `summary` from the json data can be easily checked for +warnings/expirations using a variety of command-line tools. + +For exampe, using `grep` we can look for the word `summary` and print +out the 2 lines **after** the match (`-A2`): + +``` +$ grep -A2 summary /tmp/cert-expiry-report.json + "summary": { + "warning": 16, + "expired": 0 +``` + +If available, the [jq](https://stedolan.github.io/jq/) tool can also +be used to pick out specific values. Example 1 and 2 below show how to +select just one value, either `warning` or `expired`. Example 3 shows +how to select both values at once: + +``` +$ jq '.summary.warning' /tmp/cert-expiry-report.json +16 +$ jq '.summary.expired' /tmp/cert-expiry-report.json +0 +$ jq '.summary.warning,.summary.expired' /tmp/cert-expiry-report.json +16 +0 +``` + Requirements ------------ -- cgit v1.2.1