Question on Numerical or Int-Based Conditionals [ANSWERED]
So, I'm trying to make a playbook-block only execute if a given RPM is less than a specific major version. Capture my RPM information to a JSON struct by registering the output to a variable, like:
- name: Check installed CUDA version
yum:
list=cuda
register: cuda_pkginfo
I then set a when
conditional on a block of directives. I've tried various iterations of my conditional.
when:
cuda_pkginfo.results[0].version.split('.')[0] < 11
Which, when the RPM version is 10.x returns the string-value of "10", while:
when:
cuda_pkginfo.results[0].version.split('.')[0]|int < 11
Even though I attempt to cast-to-int (via the |int
Jinja-filter), the LHS part of the evaluation is getting treated as a string rather than a number.
In either case it causes the <
evaluation to always return true (LHS is < the numerical-value "11").
Anyone know how to ensure that my LHS is a numerical value so that it can correctly be evaluated against an numberical RHS value?