summaryrefslogtreecommitdiffstats
path: root/lib/ansible/plugins/filter/human_readable.yml
blob: e3028ac54907304cb8b139e710e3c4c2a58b1617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
DOCUMENTATION:
  name: human_redable
  version_added: "historical"
  short_description: Make bytes/bits human readable
  description:
    - Convert byte or bit figures to more human readable formats.
  positional: _input, isbits, unit
  options:
    _input:
      description: Number of bytes, or bits. Depends on I(isbits).
      type: int
      required: true
    isbits:
      description: Whether the input is bits, instead of bytes.
      type: bool
      default: false
    unit:
      description: Unit to force output into. If none specified the largest unit arrived at will be used.
      type: str
      choices: [ 'Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'K', 'B']
EXAMPLES: |

  # size => "1.15 GB"
  size: "{{ 1232345345 | human_readable }}"

  # size => "1.15 Gb"
  size_bits: "{{ 1232345345 | human_readable(true) }}"

  # size => "1175.26 MB"
  size_MB: "{{ 1232345345 | human_readable(unit='M') }}"

RETURN:
  _value:
    description: Human readable byte or bit size.
    type: str