Unexpected templating type error occurred on ({{ encrypted_var }}): can only concatenate str (not \”AnsibleVaultEncryptedUnicode\”) to str

Pedro Gomes
Apr 12, 2022

--

Seems there’s a bug (or a feature) somewhere in Ansible which doesn’t translate encrypted variables (but it works fine with vault files), so when you try to use them on a template it will fail with the error above.

To work around that, you could try setting a fact before hand which will decrypt the secure variable into a new variable.

set_fact:
pass_decoded: “{{ pass }}”

Use the new variable in the template:

Authorization: “Basic {{ (user + ‘:’ + pass_decoded)| b64encode }}”

--

--

No responses yet