Bootstrap FreeKB - Ansible - Decode a string using the b64decode filter
Ansible - Decode a string using the b64decode filter

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter c0fafd in the box below so that we can be sure you are a human.