On Fri, Jan 7, 2011 at 12:29, Marek Dohojda <chrobry@gmail.com> wrote:
> I am wondering if erb templates can parse an xml document, and input a
valid
> variable from within it? Could someone please point me in the right
direction?
I can''t tell which of these two is your problem, so please ignore the
one that doesn''t apply:
ERB templates don''t care what the content is, so you can build XML
without a problem. Just put in the normal ERB tags (<%= %>) where you
want them. ERB was designed to play nice with (X)HTML too.
If you want to read an existing XML file and use data from that in
your template, you have a different problem, but it can: you can put
*anything* into the Ruby part of an ERB template, so while it is
super-ugly you can just do this:
<% require ''rexml/document''
# ...and do whatever you normally do.
%>
However, that makes your template *full* of business logic, and that
is just icky. You would be much better using something like the
''generate'' function in puppet to run a command that can
extract the
data from the XML file, put it in a regular puppet variable, and just
reference that in the template.
Finally, please note that template expansion and the generate function
run on the *master*, not the client. If your XML file is on the
client you need a custom fact to extract and return that data to the
master before you perform the template expansion.
Regards,
Daniel
--
✉ Daniel Pittman <daniel@rimspace.net>
⌨ daniel@rimspace.net (XMPP)
☎ +1 503 893 2285
♻ made with 100 percent post-consumer electrons
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.