Typecasting in vars

32 views
Skip to first unread message

ammu...@gmail.com

unread,
Jan 7, 2015, 10:38:28 AM1/7/15
to ansible...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages