ansible.builtin.b64decode filter – Decode a Base64 string

Note

This filter plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name b64decode. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.b64decode for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.

Synopsis

  • Base64 decoding function.

  • The return value is a string.

  • Trying to store a binary blob in a string most likely corrupts the binary. To Base64 decode a binary blob, use the base64 command and pipe the encoded data through standard input. For example, in the ansible.builtin.shell module, ``cmd=”base64 –decode > myfile.bin” stdin=”{{ encoded }}”``.

Input

This describes the input of the filter, the value before | ansible.builtin.b64decode.

Parameter

Comments

Input

string / required

A Base64 string to decode.

Examples

# Base64 decode a string
lola: "{{ 'bG9sYQ==' | b64decode }}"

# Base64 decode the content of 'b64stuff' variable
stuff: "{{ b64stuff | b64decode }}"

Return Value

Key

Description

Return value

string

The contents of the Base64 encoded string.

Returned: success

Authors

  • ansible core team

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.