Reputation: 207
- debug:
var: my_list | select("greaterthan", 2) | list
vars:
my_list:
- "1"
- "2"
- "3"
Errors: '>' not supported between instances of 'str' and 'int'
I've tried my_list | int | select("greaterthan", 2) | list
but it does not give the expected result.
Upvotes: 3
Views: 5445
Reputation: 68034
Convert the items of the list to integers. For example
- debug:
msg: "{{ my_list|map('int')|select('greaterthan', 2)|list }}"
vars:
my_list:
- "1"
- "2"
- "3"
gives
"msg": [
3
]
Upvotes: 10