Ansible - Decode a string using the b64decode filter
by
Jeremy Canfield |
Updated: March 02 2022
| Ansible articles
The b64decode filter is used to decode a string. The b64encode filter is used to encode a string. In this example, base 64 string Zm9v is decoded.
Notice in this example that Zm9v is wrapped in quotes. When wrapped in quotes, Zm9v is interpreted as a string. If Zm9v were not wrapped in quotes, Zm9v would be interpreted as a variable.
- name: "decoded the 'Zm9v' string"
debug:
msg: "{{ 'Zm9v' | b64decode }}"
The following should be returned.
TASK [decode the 'Zm9v' string]
ok: [server1.example.com] => {
"msg": [
"foo"
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at