I would like to use a system fact for a host times a number/percentage as a base for a variable. What I am trying to do specifically is use the ansible_memtotal_mb value and multiply it by .80 to get a ramsize to then use in setting a Couchbase value. I have been trying different variations of the line below. I'm not ever sure that it is possible, but any help would be appreciated.
vars:
ramsize: '"{{ ansible_memtotal_mb }}" * .80'
You're really close! I use calculations to set some default java memory sizes, which is similar to what you are doing. Here's an example:
That shows a couple of things- first, it's using jinja math, so do the calculations inside the
{{ jinja }}
. Second,int
andabs
do what you'd expect- ensure the result is an unsigned integer.In your case, the correct code would be: