version_compare filter in template

18 views
Skip to first unread message

mto...@go2uti.com

unread,
Aug 2, 2016, 3:54:40 PM8/2/16
to Ansible Project

I want to make a decision in a template using the version_compare filter:

    {% if httpd_version|version_compare('2.4', '>=') %}

This fails with the message "{'msg': "TypeError: 'in <string>' requires string as left operand", 'failed': True}".

The variable 'httpd_version' contains the installed version of Apache on the host.  I derived that by using a shell task in the playbook to extract the version and then using set_fact to store it.  What is the proper method of testing the version in a template?

mto...@go2uti.com

unread,
Aug 2, 2016, 4:36:45 PM8/2/16
to Ansible Project

Okay, I don't know what it was, but the filter as written below does work.  Something else in the template was munged.  I got it working by starting over with my original template before I tried to use the version compare filter and then adding the filter back in.  This time it worked perfectly.  Of course, I didn't bother to save the munged template before starting over, so I can't compare the munged template with the working template.  What ever.  It is working,  That is all I wanted.
Reply all
Reply to author
Forward
0 new messages