If we assume that ansible_memtotal_mb
is an odd number
- debug: msg="{{ ansible_memtotal_mb }}"
How can I divide ansible_memtotal_mb
by 2, and convert the result to an integer:
- debug: msg="{{ ansible_memtotal_mb * 0.5 | int }}"
Obviously the latter did not work, because (if I am not mistaken)
ansible_memtotal_mb * 0.5
returns a string and using the int
filter, results to 0
Could you please advise?
You applied int
filter to the value 0.5
.
You wanted to apply to the result of the expression, so:
- debug: msg="{{ (ansible_memtotal_mb * 0.5) | int }}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With