Hi!

I was a bit puzzled when trying to use version_compare Jinja filter to
check that the major and minor Ansible versions are equal to some
desired value.

Here is an example playbook:

- hosts: localhost
  connection: local
  gather_facts: false

  vars:
    - ansible_ver: "2.1.2"

  tasks:
    - name: Check that Ansible major and minor versions are the same
      debug: msg="{{ ansible_ver | version_compare('2.1', '==') }}"
      # returns 'false' but I would expect it to return 'true'

    - name: Check that Ansible major and minor versions are the same
      debug: msg="{{ ansible_ver | version_compare('2.1', '==',
strict=True) }}"
      # returns 'false' as expected

(Note: In real playbooks, one would use ansible_version.full in place
of ansible_ver.)

Is this a bug or intended behavior?

If the second, how would one do comparisons that would only compare the
major and minor version, ignoring the patch level? Or achieve something
like Python's compatible release operator (~=) [1]?

Thanks and regards,
Tadej Janež

[1] https://www.python.org/dev/peps/pep-0440/#compatible-release

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to