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

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.

pass_decoded: “{{ pass }}”

Use the new variable in the template:

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




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store