Hi all! I''ve been trying to work with classes in my templates, it seems like a really useful feature. I''m running on puppet .25.5 from EPEL and really wanted to start making use of the ability to pivot on classes that have been included in the catalog. It *seems* as though the templates are only cognecent of defined classes that precede the included module in the site.pp file. Is that the expected behavior? For my testing I used the example code on the wiki, and is included in the site_syslog module <% classes.each do |klass| -%> # The class <%= klass %> is defined <% end -%> My node class as defined in site.pp the module. # Class for puppet development class site_dev { include ntp include sudo include dnsclient include site_ssh include site_ldap include site_krb5 include site_access include site_snmp include site_common include site_common::passwd include site_puppet::client include site_iptables::netmgt include site_tcpwrapper include site_nsr *include site_syslog* } With site_syslog module at the *end* of the class definition, it produced the output I expected: # The class site_dev is defined # The class site_dev is defined # The class ntp is defined # The class sudo is defined # The class dnsclient is defined # The class site_ssh is defined # The class site_ldap is defined # The class site_krb5 is defined # The class site_access is defined # The class site_snmp is defined # The class site_common is defined # The class site_common::passwd is defined # The class site_puppet is defined # The class site_puppet::client is defined # The class site_iptables is defined # The class site_iptables::netmgt is defined # The class site_tcpwrapper is defined # The class site_nsr is defined # The class site_syslog is defined *however* with the site_syslog module included higher in the list, I only get classes defined before the site_syslog module. class site_dev { include ntp include sudo include dnsclient *include site_syslog* include site_ssh include site_ldap include site_krb5 include site_access include site_snmp include site_common include site_common::passwd include site_puppet::client include site_iptables::netmgt include site_tcpwrapper include site_nsr } # The class site_dev is defined # The class site_dev is defined # The class ntp is defined # The class sudo is defined # The class dnsclient is defined # The class site_syslog is defined This may be my misunderstanding but from the docs, it seems as though I should see the first example regardless of where I include the template code... Thanks for all the help! -Confused in template land -- 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.
Hi, On Tue, Nov 23, 2010 at 11:21 AM, Alaric <paxindustria@gmail.com> wrote:> Hi all! I''ve been trying to work with classes in my templates, it seems > like a really useful feature. I''m running on puppet .25.5 from EPEL and > really wanted to start making use of the ability to pivot on classes that > have been included in the catalog. It *seems* as though the templates are > only cognecent of defined classes that precede the included module in the > site.pp file. Is that the expected behavior? For my testing I used the > example code on the wiki, and is included in the site_syslog module > > <% classes.each do |klass| -%> > # The class <%= klass %> is defined > <% end -%> > > > My node class as defined in site.pp the module. > > # Class for puppet development > class site_dev { > include ntp > include sudo > include dnsclient > include site_ssh > include site_ldap > include site_krb5 > include site_access > include site_snmp > include site_common > include site_common::passwd > include site_puppet::client > include site_iptables::netmgt > include site_tcpwrapper > include site_nsr > *include site_syslog* > } > > > With site_syslog module at the *end* of the class definition, it produced > the output I expected: > > > # The class site_dev is defined > # The class site_dev is defined > # The class ntp is defined > # The class sudo is defined > # The class dnsclient is defined > # The class site_ssh is defined > # The class site_ldap is defined > # The class site_krb5 is defined > # The class site_access is defined > # The class site_snmp is defined > # The class site_common is defined > # The class site_common::passwd is defined > # The class site_puppet is defined > # The class site_puppet::client is defined > # The class site_iptables is defined > # The class site_iptables::netmgt is defined > # The class site_tcpwrapper is defined > # The class site_nsr is defined > # The class site_syslog is defined > > > > > *however* with the site_syslog module included higher in the list, I only > get classes defined before the site_syslog module. > > > class site_dev { > include ntp > include sudo > include dnsclient > *include site_syslog* > include site_ssh > include site_ldap > include site_krb5 > include site_access > include site_snmp > include site_common > include site_common::passwd > include site_puppet::client > include site_iptables::netmgt > include site_tcpwrapper > include site_nsr > } > > # The class site_dev is defined > # The class site_dev is defined > # The class ntp is defined > # The class sudo is defined > # The class dnsclient is defined > # The class site_syslog is defined > > > This may be my misunderstanding but from the docs, it seems as though I > should see the first example regardless of where I include the template > code... >This is unfortunately true. It''s possible that this may work in a future version.> > Thanks for all the help! > > -Confused in template land > > -- > 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<puppet-users%2Bunsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Bummer! Would anyone mind if I updated to wiki to reflect that? Thanks again for the help! -a On Nov 23, 2:27 pm, Dan Bode <d...@puppetlabs.com> wrote:> Hi, > > > > > > > > > > On Tue, Nov 23, 2010 at 11:21 AM, Alaric <paxindust...@gmail.com> wrote: > > Hi all! I''ve been trying to work with classes in my templates, it seems > > like a really useful feature. I''m running on puppet .25.5 from EPEL and > > really wanted to start making use of the ability to pivot on classes that > > have been included in the catalog. It *seems* as though the templates are > > only cognecent of defined classes that precede the included module in the > > site.pp file. Is that the expected behavior? For my testing I used the > > example code on the wiki, and is included in the site_syslog module > > > <% classes.each do |klass| -%> > > # The class <%= klass %> is defined > > <% end -%> > > > My node class as defined in site.pp the module. > > > # Class for puppet development > > class site_dev { > > include ntp > > include sudo > > include dnsclient > > include site_ssh > > include site_ldap > > include site_krb5 > > include site_access > > include site_snmp > > include site_common > > include site_common::passwd > > include site_puppet::client > > include site_iptables::netmgt > > include site_tcpwrapper > > include site_nsr > > *include site_syslog* > > } > > > With site_syslog module at the *end* of the class definition, it produced > > the output I expected: > > > # The class site_dev is defined > > # The class site_dev is defined > > # The class ntp is defined > > # The class sudo is defined > > # The class dnsclient is defined > > # The class site_ssh is defined > > # The class site_ldap is defined > > # The class site_krb5 is defined > > # The class site_access is defined > > # The class site_snmp is defined > > # The class site_common is defined > > # The class site_common::passwd is defined > > # The class site_puppet is defined > > # The class site_puppet::client is defined > > # The class site_iptables is defined > > # The class site_iptables::netmgt is defined > > # The class site_tcpwrapper is defined > > # The class site_nsr is defined > > # The class site_syslog is defined > > > *however* with the site_syslog module included higher in the list, I only > > get classes defined before the site_syslog module. > > > class site_dev { > > include ntp > > include sudo > > include dnsclient > > *include site_syslog* > > include site_ssh > > include site_ldap > > include site_krb5 > > include site_access > > include site_snmp > > include site_common > > include site_common::passwd > > include site_puppet::client > > include site_iptables::netmgt > > include site_tcpwrapper > > include site_nsr > > } > > > # The class site_dev is defined > > # The class site_dev is defined > > # The class ntp is defined > > # The class sudo is defined > > # The class dnsclient is defined > > # The class site_syslog is defined > > > This may be my misunderstanding but from the docs, it seems as though I > > should see the first example regardless of where I include the template > > code... > > This is unfortunately true. It''s possible that this may work in a future > version. > > > > > > > > > > > Thanks for all the help! > > > -Confused in template land > > > -- > > 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<puppet-users%2Bunsubscribe@google groups.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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Tue, Nov 23, 2010 at 11:27:58AM -0800, Dan Bode wrote:> Hi, > > On Tue, Nov 23, 2010 at 11:21 AM, Alaric <paxindustria@gmail.com> wrote: > > > Hi all! I''ve been trying to work with classes in my templates, it seems > > like a really useful feature. I''m running on puppet .25.5 from EPEL and > > really wanted to start making use of the ability to pivot on classes that > > have been included in the catalog. It *seems* as though the templates are > > only cognecent of defined classes that precede the included module in the > > site.pp file. Is that the expected behavior? For my testing I used the > > example code on the wiki, and is included in the site_syslog module > > > > <% classes.each do |klass| -%> > > # The class <%= klass %> is defined > > <% end -%> > > This is unfortunately true. It''s possible that this may work in a future > version.I think thats near to impossible. What if I do something like $number_of_classes = inline_template(<%= classes.size) if ($number_of_classes > 10) { include class_not_previously_included } what should the value of $number_of_classes be. Should it take class_not_previously_included into account? And what if the number of included classes without class_not_previously_included is exactly 10. Then not including whould be right (because we than have 10 classes included so we dont need the extra one) and including whould be right at the same time (because whould then have 11 classes included). And now image I would say if ($number_of_classes < 10) { include foobar } and with foobar included it whould be exactly 10. -Stefan
that''s is an interesting example. If we actually did implement futures in puppet, I would expect that to result in an error. On Tue, Nov 23, 2010 at 12:07 PM, Stefan Schulte < stefan.schulte@taunusstein.net> wrote:> On Tue, Nov 23, 2010 at 11:27:58AM -0800, Dan Bode wrote: > > Hi, > > > > On Tue, Nov 23, 2010 at 11:21 AM, Alaric <paxindustria@gmail.com> wrote: > > > > > Hi all! I''ve been trying to work with classes in my templates, it > seems > > > like a really useful feature. I''m running on puppet .25.5 from EPEL > and > > > really wanted to start making use of the ability to pivot on classes > that > > > have been included in the catalog. It *seems* as though the templates > are > > > only cognecent of defined classes that precede the included module in > the > > > site.pp file. Is that the expected behavior? For my testing I used > the > > > example code on the wiki, and is included in the site_syslog module > > > > > > <% classes.each do |klass| -%> > > > # The class <%= klass %> is defined > > > <% end -%> > > > > This is unfortunately true. It''s possible that this may work in a future > > version. > > I think thats near to impossible. What if I do something like > > $number_of_classes = inline_template(<%= classes.size) > if ($number_of_classes > 10) { > include class_not_previously_included > } > > what should the value of $number_of_classes be. Should it take > class_not_previously_included into account? And what if the number of > included classes without class_not_previously_included is exactly 10. > Then not including whould be right (because we than have 10 classes > included so we dont need the extra one) and including whould be right at > the same time (because whould then have 11 classes included). And now > image I would say > if ($number_of_classes < 10) { include foobar } and with foobar included > it whould be exactly 10. > > -Stefan >-- 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.
in retrospect, it might be very presumptuous of me to assume that this use case is covered under futures. On Tue, Nov 23, 2010 at 12:19 PM, Dan Bode <dan@puppetlabs.com> wrote:> that''s is an interesting example. If we actually did implement futures in > puppet, I would expect that to result in an error. > > > On Tue, Nov 23, 2010 at 12:07 PM, Stefan Schulte < > stefan.schulte@taunusstein.net> wrote: > >> On Tue, Nov 23, 2010 at 11:27:58AM -0800, Dan Bode wrote: >> > Hi, >> > >> > On Tue, Nov 23, 2010 at 11:21 AM, Alaric <paxindustria@gmail.com> >> wrote: >> > >> > > Hi all! I''ve been trying to work with classes in my templates, it >> seems >> > > like a really useful feature. I''m running on puppet .25.5 from EPEL >> and >> > > really wanted to start making use of the ability to pivot on classes >> that >> > > have been included in the catalog. It *seems* as though the templates >> are >> > > only cognecent of defined classes that precede the included module in >> the >> > > site.pp file. Is that the expected behavior? For my testing I used >> the >> > > example code on the wiki, and is included in the site_syslog module >> > > >> > > <% classes.each do |klass| -%> >> > > # The class <%= klass %> is defined >> > > <% end -%> >> > >> > This is unfortunately true. It''s possible that this may work in a future >> > version. >> >> I think thats near to impossible. What if I do something like >> >> $number_of_classes = inline_template(<%= classes.size) >> if ($number_of_classes > 10) { >> include class_not_previously_included >> } >> >> what should the value of $number_of_classes be. Should it take >> class_not_previously_included into account? And what if the number of >> included classes without class_not_previously_included is exactly 10. >> Then not including whould be right (because we than have 10 classes >> included so we dont need the extra one) and including whould be right at >> the same time (because whould then have 11 classes included). And now >> image I would say >> if ($number_of_classes < 10) { include foobar } and with foobar included >> it whould be exactly 10. >> >> -Stefan >> > >-- 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, Nov 23, 2010 at 12:07 PM, Stefan Schulte <stefan.schulte@taunusstein.net> wrote:> I think thats near to impossible.I agree. This kind of information needs to be collected *outside* the puppet run. You could have a fact that reported the number of classes used in the previous puppet run, but that''s about it. -- 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 23 November 2010 19:27, Dan Bode <dan@puppetlabs.com> wrote:> > This is unfortunately true. It''s possible that this may work in a future > version. >It''s described by this ticket: http://projects.puppetlabs.com/issues/3049 Which you might want to add yourself as a watcher to, Alaric. -- 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.