# version\_compare not working

**URL:** <https://forum.ansible.com/t/version-compare-not-working/17745>\
**Category:** Ansible Project\
**Created:** [March 14, 2015, 7:56am UTC](https://forum.ansible.com/t/version-compare-not-working/17745 "2015-03-14T07:56:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick\_Kasten](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Rick\_Kasten](https://forum.ansible.com/u/Rick_Kasten)\
**Post date:** [March 14, 2015, 7:56am UTC](https://forum.ansible.com/t/version-compare-not-working/17745/1 "2015-03-14T07:56:02Z")

</div>

This is doing the complete opposite of matching, right?

TASK: [play | debug var=installed\_app\_version] \*\*\*  
\<10.101.1.105\>  
ok: [twp01] =\> {  
“installed\_app\_version”: “5.4.0”  
}

TASK: [play | debug var=package\_versions.app.app] \*\*\*  
\<10.101.1.105\>  
ok: [twp01] =\> {  
“package\_versions.app.app”: “5.4.0”  
}

TASK: [play | debug var={{ installed\_app\_version | version\_compare(‘package\_versions.app.app’,‘!=’) }}] \*\*\*  
\<10.101.1.105\>  
ok: [twp01] =\> {  
“True”: “True”  
}

TASK: [play | debug var={{ installed\_app\_version | version\_compare(‘package\_versions.app.app’,‘==’) }}] \*\*\*  
\<10.101.1.105\>  
ok: [twp01] =\> {  
“False”: “False”  
}

Am I missing something? These variables are identical, so ‘!=’ should resolve to “False”.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 14, 2015, 1:18pm UTC](https://forum.ansible.com/t/version-compare-not-working/17745/2 "2015-03-14T13:18:08Z")

</div>

The problem seems to be improper quoting in this part:

version\_compare(‘package\_versions.app.app’,‘==’)

You don’t want to quote the var, it should just be:

version\_compare(package\_versions.app.app,‘==’)

---

<div class="post-metadata">

**Author:** ![Rick\_Kasten](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Rick\_Kasten](https://forum.ansible.com/u/Rick_Kasten)\
**Post date:** [March 19, 2015, 2:36pm UTC](https://forum.ansible.com/t/version-compare-not-working/17745/3 "2015-03-19T14:36:28Z")

</div>

That was it
