From cb9be4ddafef9dba828ee70184e7baef668c5bbf Mon Sep 17 00:00:00 2001 From: jimwitte Date: Tue, 21 May 2019 15:31:34 -0500 Subject: [PATCH] Update get_certificate.py (#56594) * Update get_certificate.py with an example to calculate number of days until cert expires from get_certificate result. * Update lib/ansible/modules/crypto/get_certificate.py Co-Authored-By: Felix Fontein --- lib/ansible/modules/crypto/get_certificate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/crypto/get_certificate.py b/lib/ansible/modules/crypto/get_certificate.py index 3f4c45e6871..e84a6bbd1c8 100644 --- a/lib/ansible/modules/crypto/get_certificate.py +++ b/lib/ansible/modules/crypto/get_certificate.py @@ -107,6 +107,12 @@ EXAMPLES = ''' delegate_to: localhost run_once: true register: cert + +- name: How many days until cert expires + debug: + msg: "cert expires in: {{ expire_days }} days." + vars: + expire_days: "{{ (( cert.not_after | to_datetime('%Y%m%d%H%M%SZ')) - (ansible_date_time.iso8601 | to_datetime('%Y-%m-%dT%H:%M:%SZ')) ).days }}" ''' import traceback