Ansible: how-to do math and get an integer?
ansible, jinja2, python
Solution
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 }}"
Problem
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?