human_to_bytes¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- Convert a human-readable byte or bit string into a number bytes.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input string required |
human-readable description of a number of bytes. | |
| default_unit str |
Choices: Y, Z, E, P, T, G, M, K, B | Unit to assume when input does not specify it. |
| isbits bool |
If V(True), force to interpret only bit input; if V(False), force bytes. Otherwise use the notation to guess. |
Examples¶
# size => 1234803098
size: '{{ "1.15 GB" | human_to_bytes }}'
# size => 1234803098
size: '{{ "1.15" | human_to_bytes(default_unit="G") }}'
# this is an error, wants bits, got bytes
ERROR: '{{ "1.15 GB" | human_to_bytes(isbits=true) }}'
# size => 2684354560
size: '{{ "2.5 gigabyte" | human_to_bytes }}'
# size => 1073741824
size: '{{ "1 Gigabyte" | human_to_bytes }}'
# this is an error, because gigggabyte is not a valid unit
size: '{{ "1 gigggabyte" | human_to_bytes }}'
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | int | Integer representing the bytes from the input. |