That last expression is too quoty (and missing a close parenthesis). Try
{{ my | selectattr('vers', 'version', '5', '<') }}
On Monday, March 6, 2023 at 9:56:50 AM UTC-5 Kai Stian Olstad wrote:
> Hi
>
> I'm trying to use version compare in selectattr but get error message
> "Version comparison failed: '<' not supported between instances of 'int'
> and 'str'
> This is the playboot I'm using
>
> - hosts: localhost
> gather_facts: no
> vars:
> my:
> - vers: "5.43"
> - vers: "4.34"
> tasks:
> - debug:
> msg: |
> {{ my.0.vers is version("5", "<") }}
> {{ my.1.vers is version("5", "<") }}
> - debug:
> msg:
> {{ my | selectattr('vers', 'version', '"5", "<"' }}
>
>
>
> The output I get is:
>
> ansible-playboot test.yml
> PLAY [localhost] *****
>
> TASK [debug] *****
> OK: [localhost] => {}
>
> MSG:
>
> False
> True
>
> TASK [debug] *****
> fatal: [localhost]: FAILED! => {}
>
> MSG:
>
> Version comparison failed: '<' not supported between instances of 'int'
> and 'str'
>
>
>
> Anyone have any idea how to do this?
>
>
> --
> Kai Stian Olstad
>
--
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/ee0c8a1a-2ca2-4647-9944-206ec984047dn%40googlegroups.com.