ansible: sum over fact array
There are map
and sum
filters in Jinja:
- set_fact:
disk_size: "{{ (item.value.sectors | int) * (item.value.sectorsize | int) }}"
with_dict: "{{ ansible_devices }}"
register: disk_sizes
- debug: msg="{{ disk_sizes.results | map(attribute='ansible_facts.disk_size') | map('int') | sum(start=0) }}"