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 ’ 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?
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.