Jeff Falgout
2011-Apr-21 17:56 UTC
[Puppet Users] Multiple includes in a module class not "included"
Greetings - I''m trying to get multiple includes to work within a class within a module and it looks as if the just the first "include" is included ... client: Scientific Linux 6 with puppet-2.6.6-1.el6.noarch (from EPEL-testing) server: Scientific Linux 6 with puppet-server-2.6.6-1.el6.noarch (from EPEL-testing) The class: from rpm_gpg/manifests/init.pp class rpm_gpg { include "rpm_gpg::keys::spacewalk2010", "rpm_gpg::keys::jpackage" } Results in the debug output of: ################### <snip> info: Caching catalog for host.example.com debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/seluser: Found seluser default ''system_u'' for /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010 debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/selrole: Found selrole default ''object_r'' for /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010 debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/seltype: Found seltype default ''cert_t'' for /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010 debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/selrange: Found selrange default ''s0'' for /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010 debug: Creating default schedules debug: Finishing transaction 69846915371360 with 0 changes debug: Loaded state in 0.00 seconds debug: /Stage[main]/Rpm_gpg::Keys/Exec[/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/subscribe: subscribes to File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010] info: Applying configuration version ''1303407573'' debug: file_metadata supports formats: b64_zlib_yaml marshal pson raw yaml; using pson debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: Changing ensure debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: 1 change(s) debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/checksum: Initializing checksum hash debug: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: Creating checksum {md5}3470111d721a8c896d5f0ca04169c69d debug: file_metadata supports formats: b64_zlib_yaml marshal pson raw yaml; using pson notice: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]/ensure: content changed ''{md5}3470111d721a8c896d5f0ca04169c69d'' to ''{md5}3470111d721a8c896d5f0ca04169c69d'' info: /File[/etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: Scheduling refresh of Exec[/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010] debug: Time for triggering 1 events to edges: 0.000894069671630859 notice: /Stage[main]/Rpm_gpg::Keys/Exec[/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: Triggering ''refresh'' from 1 dependencies debug: /Stage[main]/Rpm_gpg::Keys/Exec[/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010]: Executing ''/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010'' debug: Executing ''/bin/rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2010'' debug: Time for triggering 1 events to edges: 0.000138044357299805 debug: Finishing transaction 69846915351640 with 1 changes debug: Storing state debug: Stored state in 0.01 seconds notice: Finished catalog run in 0.66 seconds ########### The first include completes as expected, but the second include gets ignored. The rest of the module''s classes: rpm_gpg/manifests/keys/spacewalk2010.pp class rpm_gpg::keys::spacewalk2010 { $keyfilename = "RPM-GPG-KEY-spacewalk-2010" include rpm_gpg::keys } rpm_gpg/manifests/keys/jpackage.pp class rpm_gpg::keys::jpackage { $keyfilename = "RPM-GPG-KEY-jpackage" include rpm_gpg::keys } rpm_gpg/manifests/keys.pp class rpm_gpg::keys { file { "/etc/pki/rpm-gpg/$keyfilename": source => "puppet:///modules/rpm_gpg/$keyfilename", ensure => present, mode => 644, owner => root, group => root } exec { "/bin/rpm --import /etc/pki/rpm-gpg/$keyfilename": subscribe => File["/etc/pki/rpm-gpg/$keyfilename"], refreshonly => true } } I''ve come across this bug/feature request in the mailing list: http://www.mail-archive.com/puppet-bugs@googlegroups.com/msg03637.html but I''m not sure this is related.... Any help would be appreciated. Jeff -- 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.
Nigel Kersten
2011-Apr-21 18:13 UTC
Re: [Puppet Users] Multiple includes in a module class not "included"
On Thu, Apr 21, 2011 at 10:56 AM, Jeff Falgout <jtfalgout@gmail.com> wrote:> Greetings - > I''m trying to get multiple includes to work within a class within a module > and it looks as if the just the first "include" is included ... > client: Scientific Linux 6 with puppet-2.6.6-1.el6.noarch (from > EPEL-testing) > server: Scientific Linux 6 with puppet-server-2.6.6-1.el6.noarch (from > EPEL-testing) > > The class: > from rpm_gpg/manifests/init.pp > class rpm_gpg { > include > "rpm_gpg::keys::spacewalk2010", > "rpm_gpg::keys::jpackage" > }I can''t reproduce this one no matter how I jiggle the classes and include lines. root@devlucid:/home/nigel/src/puppet# puppet --version 2.6.8 root@devlucid:/home/nigel/src/puppet# cat /tmp/test.pp class rpm_gpg::keys::spacewalk2010 { notice("spacewalk class") } class rpm_gpg::keys::jpackage { notice("jpackage class") } class rpm_gpg { include "rpm_gpg::keys::spacewalk2010", "rpm_gpg::keys::jpackage" } include rpm_gpg root@devlucid:/home/nigel/src/puppet# puppet apply -v /tmp/test.pp notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class info: Applying configuration version ''1303409507'' notice: Finished catalog run in 0.02 seconds -- 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.
Jeff Falgout
2011-Apr-21 18:45 UTC
Re: [Puppet Users] Multiple includes in a module class not "included"
On Thu, Apr 21, 2011 at 12:13 PM, Nigel Kersten <nigel@puppetlabs.com>wrote:> > > > > The class: > > from rpm_gpg/manifests/init.pp > > class rpm_gpg { > > include > > "rpm_gpg::keys::spacewalk2010", > > "rpm_gpg::keys::jpackage" > > } > > > > root@devlucid:/home/nigel/src/puppet# cat /tmp/test.pp > class rpm_gpg::keys::spacewalk2010 { > notice("spacewalk class") > } > > > root@devlucid:/home/nigel/src/puppet# puppet apply -v /tmp/test.pp > notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class > notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class > info: Applying configuration version ''1303409507'' > notice: Finished catalog run in 0.02 seconds > >Interesting - that also works for me... But when I add in a subclass, it only gets executed once: # cat test.pp class rpm_gpg::keys::spacewalk2010 { $string = "SPACEWALK" include rpm_gpg::keys notice("spacewalk class") } class rpm_gpg::keys::jpackage { $string = "JPACKAGE" include rpm_gpg::keys notice("jpackage class") } class rpm_gpg::keys { notice("$string") notice("this should be included twice") } class rpm_gpg { include "rpm_gpg::keys::spacewalk2010", "rpm_gpg::keys::jpackage" } include rpm_gpg # puppet apply -v test.pp notice: Scope(Class[Rpm_gpg::Keys]): SPACEWALK notice: Scope(Class[Rpm_gpg::Keys]): this should be included twice notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class info: Applying configuration version ''1303297974'' notice: Finished catalog run in 0.07 seconds I suspect I''m doing something incorrect or misunderstanding something. Jeff -- 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.
Nan Liu
2011-Apr-21 19:10 UTC
Re: [Puppet Users] Multiple includes in a module class not "included"
On Thu, Apr 21, 2011 at 11:45 AM, Jeff Falgout <jtfalgout@gmail.com> wrote:> > > > On Thu, Apr 21, 2011 at 12:13 PM, Nigel Kersten <nigel@puppetlabs.com> > wrote: >> >> > >> > The class: >> > from rpm_gpg/manifests/init.pp >> > class rpm_gpg { >> > include >> > "rpm_gpg::keys::spacewalk2010", >> > "rpm_gpg::keys::jpackage" >> > } >> >> >> >> root@devlucid:/home/nigel/src/puppet# cat /tmp/test.pp >> class rpm_gpg::keys::spacewalk2010 { >> notice("spacewalk class") >> } >> >> >> root@devlucid:/home/nigel/src/puppet# puppet apply -v /tmp/test.pp >> notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class >> notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class >> info: Applying configuration version ''1303409507'' >> notice: Finished catalog run in 0.02 seconds >> > > > Interesting - that also works for me... > But when I add in a subclass, it only gets executed once: > # cat test.pp > class rpm_gpg::keys::spacewalk2010 { > $string = "SPACEWALK" > include rpm_gpg::keys > notice("spacewalk class") > } > class rpm_gpg::keys::jpackage { > $string = "JPACKAGE" > include rpm_gpg::keys > notice("jpackage class") > } > class rpm_gpg::keys { > notice("$string") > notice("this should be included twice") > } > class rpm_gpg { > include > "rpm_gpg::keys::spacewalk2010", > "rpm_gpg::keys::jpackage" > } > include rpm_gpg > > # puppet apply -v test.pp > notice: Scope(Class[Rpm_gpg::Keys]): SPACEWALK > notice: Scope(Class[Rpm_gpg::Keys]): this should be included twice > notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class > notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class > info: Applying configuration version ''1303297974'' > notice: Finished catalog run in 0.07 seconds > > I suspect I''m doing something incorrect or misunderstanding something.Puppet classes are singletons, even if you include a class multiple times it only realize the resources defined in the class once. class a { notify { "hello": } } class b { include a } class c { include a } include a include a, b include a, c include b, c include a, b, c All declarations above will result in a single instance of class a and only one notify resource. 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.
Jeff Falgout
2011-Apr-21 19:40 UTC
Re: [Puppet Users] Multiple includes in a module class not "included"
On Thu, Apr 21, 2011 at 1:10 PM, Nan Liu <nan@puppetlabs.com> wrote:> > > > > I suspect I''m doing something incorrect or misunderstanding something. > > Puppet classes are singletons, even if you include a class multiple > times it only realize the resources defined in the class once. >Ahhh - ok, makes sense.> > All declarations above will result in a single instance of class a and > only one notify resource. > >With that in mind, Is there an efficient way to call exec multiple times while just changing the arguments to the exec command? Jeff -- 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.
Nan Liu
2011-Apr-21 20:16 UTC
Re: [Puppet Users] Multiple includes in a module class not "included"
On Thu, Apr 21, 2011 at 12:40 PM, Jeff Falgout <jtfalgout@gmail.com> wrote:> > > On Thu, Apr 21, 2011 at 1:10 PM, Nan Liu <nan@puppetlabs.com> wrote: >> >> > >> > I suspect I''m doing something incorrect or misunderstanding something. >> >> Puppet classes are singletons, even if you include a class multiple >> times it only realize the resources defined in the class once. > > Ahhh - ok, makes sense. > >> >> All declarations above will result in a single instance of class a and >> only one notify resource. >> > > With that in mind, Is there an efficient way to call exec multiple times > while just changing the arguments to the exec command?Defined resource type is what you are looking for: http://docs.puppetlabs.com/guides/language_guide.html 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.