Typecasting in vars

Hi there,

I’m working on moving my conditions from my when statements into proper vars but I’m having problems with typecasting.

In an Ansible role I could do something like

  • debug: msg=“Hi”
    when: (ansible_distribution == ‘CentOS’ or ansible_distribution == ‘Redhat’)
    and ansible_distribution_major_version | int >= 7

But obviously the ‘| int’ part was to do with Jinja formatting so I can’t use this in vars. I wanted to be able to assign that condition to a variable and then all I have to do is call something like ‘when: el_gt_7’

Can someone tell me if this is possible?

Thanks,
Allan