I need to do base64 encoding of something like: "https://myurl.com". Because there is a colon in that string, I need to enclose everything in quotes. So I have something like:
- name: do the encode
shell: 'echo "https://myurl.com" | /usr/bin/base64'
register: bvalue
But I get a blank when I use:
{{ bvalue.stdout }}
So I want to use the Ansible construct, but I don't know how and the documentation is not clear. It's something like:
- name: do the encode
shell: '{{ "https://myurl.com" | b64encode }}'
But I know that is wrong. And I can't find any examples. Help!
I think this is how to do it. Define a variable in a playbook:
MYVAR: "https://myurl.com"
Then in the role, do:
- name: do the encode
shell: echo {{ MYVAR | b64encode }} > /tmp/output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With