using heredoc in an erb template with hiera

364 views
Skip to first unread message

Mark Rosedale

unread,
Feb 18, 2015, 1:08:37 PM2/18/15
to puppet...@googlegroups.com
Hello,

I'm using hiera with puppet 3.7. What I need to do is pass in a formatted string to puppet to be used inside an erb template. What I'd really like is to use heredoc, but it doesn't seem like that is going to work. Does anyone have information on this and whether it is possible or not? 

Thanks

Christopher Wood

unread,
Feb 18, 2015, 2:27:00 PM2/18/15
to puppet...@googlegroups.com
I tend to go for the lazy way, create my complicated string in something like a perl data structure where the language understand here docs and then dump it out to yaml. That way I have a set of yaml that I can copy into my hiera data.

It ends up hideous but usable (note line breaks):

---
key: this is the value of a key
long: "really really long really really long really really long really really long really really long really really long really really long \n\nreally really long really really long really really long really really long really really long really really long really really long really really long \n\n\nreally really long really really long really really long "

Otherwise I might encrypt it via hiera-eyaml, using the encryption as a fake-base64.

Or maybe store it like you would binary data in yaml, aka base64 itself? Not tried this one myself.

http://yaml.org/type/binary.html
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/b3462d5f-b0a9-4c02-9266-6f64beef3458%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/b3462d5f-b0a9-4c02-9266-6f64beef3458%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Angel L. Mateo

unread,
Feb 19, 2015, 3:31:27 AM2/19/15
to puppet...@googlegroups.com
El 18/02/15 a las 19:08, Mark Rosedale escribió:
Do you mean the | of the yaml? Like this?

my_formated_option: |
This is just a long formated text
more text
blah...
....
and this is the final
other_option: other_value

--
Angel L. Mateo Martínez
Sección de Telemática
Área de Tecnologías de la Información
y las Comunicaciones Aplicadas (ATICA)
http://www.um.es/atica
Tfo: 868887590
Fax: 868888337
Reply all
Reply to author
Forward
0 new messages