Reputation: 14226
I was having an issue in my Ansible template where I wanted to create an HTTP basic auth credential out of two different variables a user inputs into the play.
The first thing I tried to do was:
basic_auth: "{{ user + ':' + pass | b64encode }}"
However I ended up with:
basic_auth: "user:<BASE64_ENCODED>"
How can I have Jinja concatenate these strings and then pass it through my filter?
Upvotes: 6
Views: 11904
Reputation: 14226
Pretty basic solution: group with parenthesis.
basic_auth: "{{ (user + ':' + pass) | b64encode }}"
I assume that this will allow me to nest several layers of filters.
complex: "{{ ((user + ':' + pass) | b64encode) | complex_filter}}"
Upvotes: 11