# Typecasting in vars

**URL:** <https://forum.ansible.com/t/typecasting-in-vars/17208>\
**Category:** Ansible Project\
**Created:** [January 7, 2015, 3:38pm UTC](https://forum.ansible.com/t/typecasting-in-vars/17208 "2015-01-07T15:38:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ammullan](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@ammullan](https://forum.ansible.com/u/ammullan)\
**Post date:** [January 7, 2015, 3:38pm UTC](https://forum.ansible.com/t/typecasting-in-vars/17208/1 "2015-01-07T15:38:28Z")

</div>

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
