FWIW, the `version` test is implemented via
`distutils.version.LooseVersion` (by default)

And based on the documentation:

> there is no such thing as an invalid version number under this scheme;
> the rules for comparison are simple and predictable, but may not always
give the results you want (for some definition of "want").

Due to the implementation details of basically comparing a python tuple,
`10` is less than `10.0`

>>> LooseVersion('10') < LooseVersion('10.0')
True
>>> (10,) < (10, 0)
True

To get equality, you'll have to perform some normalization on your versions
first, and while there are some ways you can use existing jinja operations
to do so, it may require assumptions on your data that could just as easily
cause problems in the future.

On Wed, Sep 15, 2021 at 2:54 PM Andy Smith <[email protected]> wrote:

> Hello,
>
> On Wed, Sep 15, 2021 at 10:52:23AM +0200, Dick Visser wrote:
> > Instead of trying to make (to me rather arbitrary) comparisons between
> > 10 and 10.0, I'd investigate why ansible_distribution_version for your
> > OS has no 'decimals' to begin with.
>
> I think it's because none of the point releases for Debian 10 have
> been installed on that host, so it's not received any update to the
> base-files package (for /etc/os-release) that would show the point
> release (e.g. 10.10).
>
> $ head -3 /etc/os-release
> PRETTY_NAME="Debian GNU/Linux 10 (buster)"
> NAME="Debian GNU/Linux"
> VERSION_ID="10"
>
> But this is besides the point as it is normal for a Debian release
> to show as not having decimals for some period of time. So we do have
> to be aware what testing ansible_distribution_version against x.0
> will do, apparently. Whether that test is newer, older or equality.
>
> Cheers,
> Andy
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/20210915195444.epxuwx3pszjfgspl%40bitfolk.com
> .
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v8MtQErjoQVzQuM%2Bbrqf9tNBebjJdBmZ%3D8%2BrUXiroc2NA%40mail.gmail.com.

Reply via email to