Erb template

47 views
Skip to first unread message

Manoj Muraleedharan

unread,
May 2, 2016, 12:29:51 PM5/2/16
to Puppet Users
I have two erb template, one for main config file and another for child process config file. I need to want to create config file for 3 child process config file inside main erb template by calling another erb template inside. these 3 config files has to be three different name.

I need the following config file create in my puppet agent
/etc/app/main.conf
/etc/app/child1.conf
/etc/app/child2.conf
/etc/app/child3.conf

I have two erb file in my modeule main.erb and child.erb

I want to call only the main.erb and when processing main.erb i need to create the above child.conf file based on child.erb

Lowe Schmidt

unread,
May 3, 2016, 2:36:08 AM5/3/16
to puppet...@googlegroups.com
It is probably better two generate the child*.conf from your puppet code rather than having an erb template generate another file (I am not even sure that works).

What version of puppet are you running and could you show us some code?

--
Lowe Schmidt | +46 723 867 157

--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8d13593d-3117-44bf-9132-e4d4e084341b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Kristolaitis

unread,
May 3, 2016, 3:00:29 AM5/3/16
to puppet...@googlegroups.com

I can't see how this would work at all, given that templates are filled out by the Puppet master and sent to the client.  Even if you used "pure Ruby" inside the ERB to process another ERB file, the Puppet master would have no way to know that it's supposed to pick up that other file and include it in the node's catalog.

This is almost certainly required to be handled in Puppet code with explicit resources, probably through one or more abstraction classes.

- Peter

jcbollinger

unread,
May 3, 2016, 9:24:03 AM5/3/16
to Puppet Users


As Peter observed, Puppet templates are evaluated on the master.  Even if a template created additional outputs as a side effect of its evaluation, you would need to declare a File resource corresponding to each one for that to be in any way usable, and at that point I don't see what's to be gained by driving the whole thing from one master template.

Even if you were using 'puppet apply', so that in principle, Ruby scriptlet code in the template could indeed drop files in arbitrary places on the target file system, you probably still would not want to do that.  There is a variety of reasons why you want to be sure that Puppet knows what resources it is actually managing.

My best guess as to why you think you want to do this is that you are performing some kind of computation in the main ERB whose results you want to (re)use to build the child configs.  If that's the case, then you are doing too much work in your template.  Factor out any such code into the host Puppet manifest or into a custom function.


John

Reply all
Reply to author
Forward
0 new messages