Here is an example using inline templates. Should describe how you can do it.
class myclass { } class myclass::config { $myvar = "this is class text" } class myclass::template { include myclass::config $myvar = $myclass::config::myvar $mytemplate = inline_template(" Here is some text. Myvar should go here: <% if has_variable?('myvar') -%> <% if myvar =~ /text/ -%> <%= myvar %> this is your node var: <%= scope.lookupvar('nodevar') -%> <% else -%> Don't put text in. <% end -%> <% end -%> ") notify {$mytemplate: } } node default { $nodevar = 'this is node text' include myclass::template } notice: /Stage[main]/Myclass::Template/Notify[ Here is some text. Myvar should go here: this is class text this is your node var: this is node text]/message: current_value absent, should be Here is some text. Myvar should go here: this is class text this is your node var: this is node text (noop) notice: Class[Myclass::Template]: Would have triggered 'refresh' from 1 events notice: Stage[main]: Would have triggered 'refresh' from 1 events notice: Finished catalog run in 0.07 seconds In version 2.7.10 (which I'm using) I get a deprecation warning while trying to access the node variable - I don't declare variables that way so I don't know off hand how to fix it (tried several ways quickly). That should give you an idea anyway. Den On Fri, Mar 2, 2012 at 4:54 PM, Will S. G. <w...@arw.in> wrote: > I'm not being descriptive, I know. I'll clarify as pseudo-code; I'm > essentially attempting to declare a variable in node.pp as such: > > node 'util-mysql0' inherits default { > $mysqlsr = [define value] > .... > } > > So: > > - Define variable > - Create the condition in the template > - If var condition is met. Add line to the file for that node. > - Rinse, lather and repeat. > > As you can see, by defining the variable, I'm attempting to predefine the > condition. I would like to re-write the template, rather include the extra > line (the aforementioned) when the variable is defined for the node. If my > approach is incorrect, I suppose I would ask that you let me know. If not > then, please let me know what I might be missing. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/kT1GluO0QTkJ. > > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.