Skip to content

1 FAQ: Integers being passed as string

Yuwei Zhou edited this page May 13, 2019 · 1 revision

Real case: ansible/ansible#47696

Especially in azure_rm_deployment module. Some modules accept a parameter no matter in string or int format. Usually, user pass 10 as an integer. However this snippet pass string parameter:

- set_fact:
     my_num: 10
- debug:
     var: "{{ my_num|int }}"

To solve this problem, user need to enable native jinjia2 syntax via one of the following 2 options

  • [Option 1] the ansible.cfg config setting is jinja2_native in the defaults section. (ref)
  • [Option 2] export ANSIBLE_JINJA2_NATIVE=true (ref)