Hi All,
Im having trouble with setting a fact, doing some math, and having the
result be an INT
To start, i set the base Var
set_fact: SOMENUMBER = 8
Ansible stores this value as a String
Later, i need to divide that number by 2 and get the result as an INT
set_fact: myvar = "{{ SOMENUMBER / 2) }}"
Even then though, Ansible stores it as a string.
If I do this, i get an INT, but its a FLOAT 4.0 instead of 4
set_fact: myvar = "{{ ((SOMENUMBER|int) / 2) }}"
I am having to resort to doing the following to get my answer of 4
set_fact: myvar = "{{ ((SOMENUMBER|int) / 2)|replace('.0','') }}"
Is there a better way to take a single integer stored as a string, and
perform math and output an INT more simply?
TIA!
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ee3082ca-cfc9-42de-b139-eac9754bef23%40googlegroups.com.