A few weeks ago, you guys helped me get the sum of gluster healings occurring on our gluster volumes. So now I have 3 facts that have sums of each of our 3 volumes. I’d like to sum those now as its own fact, but its giving me the output as a string. How can I actually sum the 3 values?
name: Get healing total
set_fact:
total: “{{ home_sum|int }} + {{ nas_sum|int }} + {{ projects_sum|int }}”
home_sum is 2, nas_sum is 0, and projects_sum is 0. So I’d assume that the sum would be 2, however what is being calculated for the fact “total” is “2+0+0”. I need the actual sum.
- name: Get healing total
set_fact:
total: "{{ home_sum|int }} + {{ nas_sum|int }} + {{ projects_sum|int }}"
You go in and out of jinja templating, but the entire expression is
still a string.
home_sum is 2, nas_sum is 0, and projects_sum is 0. So I'd assume that the sum would be 2, however what is being calculated for the fact "total" is "2+0+0". I need the actual sum.
Doing the calculation entirely in jinja should work, i.e.:
A few weeks ago, you guys helped me get the sum of gluster healings occurring on our gluster volumes. So now I have 3
facts that have sums of each of our 3 volumes. I'd like to sum those now as its own fact, but its giving me the output
as a string. How can I actually sum the 3 values?
- name: Get healing total
set_fact:
total: "{{ home_sum|int }} + {{ nas_sum|int }} + {{ projects_sum|int }}"
home_sum is 2, nas_sum is 0, and projects_sum is 0. So I'd assume that the sum would be 2, however what is being
calculated for the fact "total" is "2+0+0". I need the actual sum.
You are asking for separate calculations by using curly braces for each sum.