In the puppet documentation, it is stated: "You can also use templates to fill in variables in addition to filling out file contents." template(''/path/to/template1'',''/path/to/template2'') My question: is this done in the ERB file, or in the puppet manifest? If done in the ERB file, I assume it also has to be within <% %> tags, but unlike all the other examples in the documentation it is not presented this way. The /path/to/ - is there some way to properly do this, or do I need to do ''/etc/puppet/files/templates/...../foo.erb'' ? Thanks! -- 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.
On Wed, Apr 6, 2011 at 2:54 PM, draeath <draeath@gmail.com> wrote:> In the puppet documentation, it is stated: > > "You can also use templates to fill in variables in addition to > filling out file contents." > template(''/path/to/template1'',''/path/to/template2'')I don''t have the specific document, so not sure if I''m missing any context, I presume this simply means: $foo = template(''/path/to/foo.erb'') file { ''/etc/a'': content => template(''/path/to/foo.erb'') }> My question: is this done in the ERB file, or in the puppet manifest? > If done in the ERB file, I assume it also has to be within <% %> tags, > but unlike all the other examples in the documentation it is not > presented this way. > > The /path/to/ - is there some way to properly do this, or do I need to > do ''/etc/puppet/files/templates/...../foo.erb'' ?Please follow the modules convention: http://docs.puppetlabs.com/guides/modules.html For portability, place the file in $module_name/templates/ directory and use the module name: $foo = template("${module_name}/foo.erb") Thanks, Nan -- 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.
That didn''t exactly help me out. I would like to include one .erb from inside another .erb (vs concatenating .erbs together, which is what I''m gathering is what happens when done in the manifest). The file path I gave was an example, as the one given is written in a way that suggests absolute system paths. This is the entry in question: http://docs.puppetlabs.com/guides/templating.html#combining-templates On Apr 6, 6:48 pm, Nan Liu <n...@puppetlabs.com> wrote:> On Wed, Apr 6, 2011 at 2:54 PM, draeath <drae...@gmail.com> wrote: > > In the puppet documentation, it is stated: > > > "You can also use templates to fill in variables in addition to > > filling out file contents." > > template(''/path/to/template1'',''/path/to/template2'') > > I don''t have the specific document, so not sure if I''m missing any > context, I presume this simply means: > > $foo = template(''/path/to/foo.erb'') > > file { ''/etc/a'': > content => template(''/path/to/foo.erb'') > > } > > My question: is this done in the ERB file, or in the puppet manifest? > > If done in the ERB file, I assume it also has to be within <% %> tags, > > but unlike all the other examples in the documentation it is not > > presented this way. > > > The /path/to/ - is there some way to properly do this, or do I need to > > do ''/etc/puppet/files/templates/...../foo.erb'' ? > > Please follow the modules convention:http://docs.puppetlabs.com/guides/modules.html > > For portability, place the file in $module_name/templates/ directory > and use the module name: > $foo = template("${module_name}/foo.erb") > > Thanks, > > Nan-- 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.
On Wed, Apr 06, 2011 at 02:54:43PM -0700, draeath wrote:> "You can also use templates to fill in variables in addition to > filling out file contents." > template(''/path/to/template1'',''/path/to/template2'')This is for in the manifest, so combing them. [ben@Paresthesia:~]% cat erb.pp file{ ''/Users/ben/test'': content => template(''/Users/ben/one.erb'',''/Users/ben/two.erb'') } [ben@Paresthesia:~]% cat one.erb I am the <%= fqdn %> [ben@Paresthesia:~]% cat two.erb I am in the other file and am <%= virtual %> [ben@Paresthesia:~]% puppet apply erb.pp notice: Finished catalog run in 0.02 seconds [ben@Paresthesia:~]% cat test I am the Paresthesia.local I am in the other file and am physical> My question: is this done in the ERB file, or in the puppet manifest?It''s in the manifest.> If done in the ERB file, I assume it also has to be within <% %> tags, > but unlike all the other examples in the documentation it is not > presented this way.I don''t think you can embed ERB inside more ERB. I tried a couple of attempts and Ruby really wasn''t keen on the idea.> The /path/to/ - is there some way to properly do this, or do I need to > do ''/etc/puppet/files/templates/...../foo.erb'' ?$mypath = ''/etc/puppet/files/templates/...../'' file{ ''/tmp/foo'': content => template( "$mypath/foo.erb" ) } Or if using modules, you can just specify the module name and it will use the template named in there. content => template( ''mymodule/mytemplate.erb'' ) From mymodule/templates/mytemplate.erb -- Ben Hughes || http://www.puppetlabs.com/ -- 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.
This is actually quite easy. You just need to call the template() function from the erb template. For example: #!/bin/sample_script_erb some commands here <%= scope.function_template("module_name/template_file.erb") %> some more commands here On 4/6/11 11:48 PM, Ben Hughes wrote:> On Wed, Apr 06, 2011 at 02:54:43PM -0700, draeath wrote: > >> "You can also use templates to fill in variables in addition to >> filling out file contents." >> template(''/path/to/template1'',''/path/to/template2'') > This is for in the manifest, so combing them. > > [ben@Paresthesia:~]% cat erb.pp > file{ ''/Users/ben/test'': > content => template(''/Users/ben/one.erb'',''/Users/ben/two.erb'') > } > [ben@Paresthesia:~]% cat one.erb > I am the<%= fqdn %> > [ben@Paresthesia:~]% cat two.erb > I am in the other file and am<%= virtual %> > [ben@Paresthesia:~]% puppet apply erb.pp > notice: Finished catalog run in 0.02 seconds > [ben@Paresthesia:~]% cat test > I am the Paresthesia.local > I am in the other file and am physical > >> My question: is this done in the ERB file, or in the puppet manifest? > It''s in the manifest. > >> If done in the ERB file, I assume it also has to be within<% %> tags, >> but unlike all the other examples in the documentation it is not >> presented this way. > I don''t think you can embed ERB inside more ERB. I tried a couple of > attempts and Ruby really wasn''t keen on the idea. > >> The /path/to/ - is there some way to properly do this, or do I need to >> do ''/etc/puppet/files/templates/...../foo.erb'' ? > $mypath = ''/etc/puppet/files/templates/...../'' > file{ ''/tmp/foo'': > content => template( "$mypath/foo.erb" ) > } > > Or if using modules, you can just specify the module name and it will use > the template named in there. > > content => template( ''mymodule/mytemplate.erb'' ) > > From mymodule/templates/mytemplate.erb >-- 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.