base64 within module

607 views
Skip to first unread message

Luca Gioppo

unread,
Oct 15, 2012, 3:51:43 AM10/15/12
to puppet...@googlegroups.com
I have to convert a string in base64 before placing it inside a template with puppet.
Is there a function available and how?
Thanks
Luca

R.I.Pienaar

unread,
Oct 15, 2012, 3:58:43 AM10/15/12
to puppet...@googlegroups.com
not sure if there's a puppet function - do not think so. but if you're
just going to use it in the template as base64 then do this in your
template:

require 'base64'
Base64.encode64(yourvar)

the 'require' line is probably not needed

Paul Tötterman

unread,
Oct 15, 2012, 4:00:14 AM10/15/12
to puppet...@googlegroups.com
Hi Luca,

I have to convert a string in base64 before placing it inside a template with puppet.
Is there a function available and how?

Puppet templates are embedded ruby, and you can do almost anything you can with regular ruby. So you the Base64 module from ruby:

<%
require 'base64'
%>
<%= Base64.encode64('foobar') %>

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages