Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use ansible b64encode

Tags:

base64

ansible

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!

like image 361
Nova Avatar asked Apr 10 '14 03:04

Nova


1 Answers

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
like image 178
Nova Avatar answered Oct 08 '22 19:10

Nova