how to compare two dates (possibly in different format) in jinja2 templates ?

407 views
Skip to first unread message

ishan jain

unread,
Jul 28, 2016, 2:23:34 PM7/28/16
to Ansible Project
I am writing a template in which the warning output is generated if the winRM certificate of target windows host is going to expire in 1 month. I just don't see a way how can i compare two dates in jinja2 template.

I have the winrm certificate expiration time in the fact - ansible_winrm_certificate_expires

Now the comparison will look something like this in template:


Check WinRM certificate
{% for i in play_hosts %}
{% if  hostvars[i].ansible_winrm_certificate_expires compared to current date %}
{{ i }}: Warning - WinRM certificate expires in 1 month
{% endif %}
{% endfor %}


Any way of comparing dates here ?
Reply all
Reply to author
Forward
0 new messages