Hi. I''m trying to accomplish something like this: node "node1" { $foo_var1 = true include foo } node "node2" { $foo_var1 = true $foo_var2 = true include foo } class foo { file { "/etc/foo.conf": content => template("foo.conf.erb"), } } And the foo.conf.erb looks like: <% defined? foo_var1 %> ... stuff to be included for nodes where foo_ is defined ... <% end %> <% defined? foo_var2 %> ... stuff to be included for nodes where foo_ is defined ... <% end %> I admit my puppet and ruby skills are poor, but I expected to get something like this for node1: ... stuff to be included for nodes where foo_ is defined ... And for node2: ... stuff to be included for nodes where foo_ is defined ... ... stuff to be included for nodes where foo_ is defined ... I''ve tried many variations on the template, but in all cases the rendered file is empty. How can I accomplish this? Include sections in the template based on the definededness of variables. 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 -~----------~----~----~----~------~----~------~--~---
OK. I screwed that up royally... sorry for not proofing before hitting send. Here is the corrected template: <% if defined? foo_var1 %> ... stuff to be included for nodes where foo_var1 is defined ... <% end %> <% if defined? foo_var2 %> ... stuff to be included for nodes where foo_var2 is defined ... <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try <% if defined? @foo_var1 %> note the @ On Tue, Sep 9, 2008 at 8:46 PM, Grumpus <grumpus@boolecat.com> wrote:> > OK. I screwed that up royally... sorry for not proofing > before hitting send. Here is the corrected template: > > > <% if defined? foo_var1 %> > ... stuff to be included for nodes where foo_var1 is defined ... > <% end %> > > <% if defined? foo_var2 %> > ... stuff to be included for nodes where foo_var2 is defined ... > <% end %> > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Actually, what version of puppet are you using? On Tue, Sep 9, 2008 at 9:31 PM, Andrew Shafer <andrew@reductivelabs.com>wrote:> > try > > <% if defined? @foo_var1 %> > > note the @ > > > > > On Tue, Sep 9, 2008 at 8:46 PM, Grumpus <grumpus@boolecat.com> wrote: > >> >> OK. I screwed that up royally... sorry for not proofing >> before hitting send. Here is the corrected template: >> >> >> <% if defined? foo_var1 %> >> ... stuff to be included for nodes where foo_var1 is defined ... >> <% end %> >> >> <% if defined? foo_var2 %> >> ... stuff to be included for nodes where foo_var2 is defined ... >> <% end %> >> >> >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 Tue, Sep 09, 2008 at 09:31:05PM -0600, Andrew Shafer wrote:> > try > > <% if defined? @foo_var1 %> > > note the @ >That didn''t seem to make a difference. And I''m using puppet 0.24.5. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It is fixed in the head of the 0.24.x branch to use @foo. You could work around for now defining all the foo_varX = false at a higher scope, then set them to true where appropriate. Then do <% if foo_var1 %> On Wed, Sep 10, 2008 at 6:45 AM, Grumpus <grumpus@boolecat.com> wrote:> > On Tue, Sep 09, 2008 at 09:31:05PM -0600, Andrew Shafer wrote: > > > > try > > > > <% if defined? @foo_var1 %> > > > > note the @ > > > > That didn''t seem to make a difference. And I''m using puppet 0.24.5. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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, Sep 10, 2008 at 09:34:52AM -0600, Andrew Shafer wrote:> > It is fixed in the head of the 0.24.x branch to use @foo. > > You could work around for now defining all the foo_varX = false at a higher > scope, then set them to true where appropriate. > > Then do > <% if foo_var1 %> > >I apologize for the late follow-up, but it took a while before I was able to try out 0.24.x. Both methods you mention work as advertised. 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 -~----------~----~----~----~------~----~------~--~---