ansible/ansible — pull request #5693 by renard (2014-01-21 00:29:02+00:00)
Title: Filter to convert size for human readable usage

Size such as disk or memory can now be converted to human readable
values in filters.

For example:

Variable is defined as:

sda_size: "{{ ansible_devices['sda'].sectors|int * ansible_devices['sda'].sectorsize|int }}"

This can be used:

- name: between 8Gb and 16Gb
command: echo "{{ sda_size }}"
when: sda_size|to_GiB <= 16 and sda_size|to_GiB > 8

New filters:

* to_KiB (binary unit 1024^1), to_KB (SI unit 1000^1)
* to_MiB (binary unit 1024^2), to_MB (SI unit 1000^2)
* to_GiB (binary unit 1024^3), to_GB (SI unit 1000^3)
* to_TiB (binary unit 1024^4), to_TB (SI unit 1000^4)