I've got a task (actually a role, but using a task here to make the example easier) that I don't own which does some operations on a variable. It assumes the variable is an integer. I need to somehow pass it a variable and have it come through as an int, and I'm not having any luck.
Here is a super simplified version of the task that I don't own:
frob.yml
- name: Validate that frob_count is <= 100
fail: msg="{{frob_count}} is greater than 100"
when: frob_count > 100
- name: Do real work
debug: msg="We frobbed {{frob_count}} times!"
My playbook is:
- name: Frob some things
hosts: localhost
vars:
things:
- parameter: 1
- parameter: 2
- parameter: 45
tasks:
- with_items: "{{things}}"
include: frob.yml
vars:
frob_count: "{{item.parameter}}"
No matter what, I get errors like "1 is greater than 100" from frob.yml
. Looks like it's getting the var as a string instead of an integer.
I've tried stuff like frob_count: "{{item.parameter | int}}"
with no luck. If I could change frob.yml
it'd be easy, but like I said, that's out of my control. Any thoughts?
This is on Ansible 2.6.4