Skip to content

Instantly share code, notes, and snippets.

@jpmens
Created February 8, 2024 16:57
Show Gist options
  • Save jpmens/588d62a7f8943535ceaaf77e09f96718 to your computer and use it in GitHub Desktop.
Save jpmens/588d62a7f8943535ceaaf77e09f96718 to your computer and use it in GitHub Desktop.
$ cat numbers.yml
- hosts: localhost
vars:
i: "17" # strings here like from register, etc.
f: "92.87"
s: "my name"
tasks:
- set_fact:
numbers:
my_i: "{{ i }}"
my_f: "{{ f }}"
my_s: "{{ s }}"
- debug: var=numbers
$ ansible-playbook numbers.yml
TASK [debug] ************************************************************************
ok: [localhost] => {
"numbers": {
"my_f": "92.87", <----- strings
"my_i": "17",
"my_s": "my name"
}
}
$ ANSIBLE_JINJA2_NATIVE=True ansible-playbook numbers.yml
TASK [debug] ************************************************************************
ok: [localhost] => {
"numbers": {
"my_f": 92.87, <----- NOT strings
"my_i": 17,
"my_s": "my name"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment