Hi, I need to print a variable as a number instead a string. Example:
- name: Create input
uri:
url: "https://{{ url_graylog }}/api/system/inputs"
...
body_format: json
body:
title: "{{ name }}"
configuration:
bind_address: "0.0.0.0"
port: "{{ port }}" <-- its print as string, I need number
global: true
I tried
port: {{ port }} <-- not work
port: "{{ port | int }}" <-- not work
Any idea? Thanks!
Values passed in using the key=value syntax are interpreted as strings. Use the JSON format if you need to pass in anything that shouldn’t be a string (Booleans, integers, floats, lists etc).
[docs.ansible.com/ansible/latest/user_guide/…port: {
it expects that to be an object literal, just like JSON, versus a jinja2 template which isport: {{
, so you must use some kind of YAML quoting; either'{{ port | int }}'
orport: >-\n {{ port | int }}
etc. We will need more details about why"{{ port | int }}" <-- not work
"{{ port | int }}"
not work as a number, only as a string. My problem is because to value is string. I need that{{ port | int }}
was number. But reading the documentation, I look this: ``` Values passed in using the key=value syntax are interpreted as strings. Use the JSON format if you need to pass in anything that shouldn’t be a string (Booleans, integers, floats, lists etc).``` :-(