I am reading from a CSV file, register a variable and loop through the variable's list. It's as easy as below example:
---
- hosts: localhost
vars:
csv: |
some;val;ues
string;1;2
tasks:
- name: copy
copy:
content: "{{csv}}"
dest: "vm.csv"
- name: read csv
community.general.read_csv:
path: "vm.csv"
delimiter: ";"
register: vms
- name: debug
debug:
var: vms
- name: Trigger AWX
awx.awx.workflow_launch:
name: "Do the job!"
extra_vars:
some_string: "{{ item.some }}"
an_integer: "{{ item.val }}"
another_integer: "{{ item.ues }}"
with_items: "{{ vms.list }}"
Now let's get into the issue. When triggering the last task, integers are required for an_integer and another_integer. Otherwise the API below will fail.
The problem: the Jinja2 template engine will ALWAYS return a string. an_integer: "{{ item.val | int }}", for example, won't change that behavior.
As you can see from the output of task 3 (debug), the values are already string when read from csv / registered.
ok: [localhost] => {
"vms": {
"changed": false,
"dict": {},
"failed": false,
"list": [
{
"some": "string",
"ues": "2",
"val": "1"
}
]
}
}
How can I force a module parameter to be set as integer?