Can someone please explain what''s happening here? Let me know if you need more info. Thanks in advance for your time. I have a module called abc. This is the init.pp for that module. ################### $ cat modules/production/abc/manifests/init.pp # Puppet Module: abc # class abc { package { "maatkit": ensure => present } } class abc::base inherits abc { exec { "testvars": command => "/bin/echo ''java_version=${java_version}''", logoutput => true; } } class abc::test { $java_version = "jdk1.6.0_14" include abc::base } ################### I accidently assigned both the "abc" and "abc::test" class to a host and noticed that the variable "java_version" no longer gets interpolated. E.g. here''s the puppet run log. # puppetd -t notice: Ignoring --listen on onetime run info: Retrieving plugin info: Caching catalog for abc1.staging.pp.com info: Applying configuration version ''1271906581'' notice: //abc::base/Exec[testvars]/returns: java_versionnotice: //abc::base/Exec[testvars]/returns: executed successfully warning: Value of ''preferred_serialization_format'' (pson) is invalid for report, using default (marshal) notice: Finished catalog run in 3.21 seconds But If I only assign the host the "abc::test" class, everything works ok like so: # puppetd -t notice: Ignoring --listen on onetime run info: Retrieving plugin info: Caching catalog for abc1.staging.pp.com info: Applying configuration version ''1271906581'' notice: //abc::base/Exec[testvars]/returns: java_version=jdk1.6.0_14 notice: //abc::base/Exec[testvars]/returns: executed successfully warning: Value of ''preferred_serialization_format'' (pson) is invalid for report, using default (marshal) notice: Finished catalog run in 3.21 seconds So I obviously know what to do to fix the problem but would love to understand what''s happening here. Regards, Sukh -- 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.
Forgot to mention that I am running version puppet-0.25.4-1 on both sides on centos 5.4. -----Original Message----- From: Sukh Khehra Sent: Wednesday, April 21, 2010 8:39 PM To: ''puppet-users@googlegroups.com'' Subject: variable interpolation weirdness Can someone please explain what''s happening here? Let me know if you need more info. Thanks in advance for your time. I have a module called abc. This is the init.pp for that module. ################### $ cat modules/production/abc/manifests/init.pp # Puppet Module: abc # class abc { package { "maatkit": ensure => present } } class abc::base inherits abc { exec { "testvars": command => "/bin/echo ''java_version=${java_version}''", logoutput => true; } } class abc::test { $java_version = "jdk1.6.0_14" include abc::base } ################### I accidently assigned both the "abc" and "abc::test" class to a host and noticed that the variable "java_version" no longer gets interpolated. E.g. here''s the puppet run log. # puppetd -t notice: Ignoring --listen on onetime run info: Retrieving plugin info: Caching catalog for abc1.staging.pp.com info: Applying configuration version ''1271906581'' notice: //abc::base/Exec[testvars]/returns: java_versionnotice: //abc::base/Exec[testvars]/returns: executed successfully warning: Value of ''preferred_serialization_format'' (pson) is invalid for report, using default (marshal) notice: Finished catalog run in 3.21 seconds But If I only assign the host the "abc::test" class, everything works ok like so: # puppetd -t notice: Ignoring --listen on onetime run info: Retrieving plugin info: Caching catalog for abc1.staging.pp.com info: Applying configuration version ''1271906581'' notice: //abc::base/Exec[testvars]/returns: java_version=jdk1.6.0_14 notice: //abc::base/Exec[testvars]/returns: executed successfully warning: Value of ''preferred_serialization_format'' (pson) is invalid for report, using default (marshal) notice: Finished catalog run in 3.21 seconds So I obviously know what to do to fix the problem but would love to understand what''s happening here. Regards, Sukh -- 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 21, 2010 at 8:42 PM, Sukh Khehra <skhehra@proofpoint.com> wrote:> Forgot to mention that I am running version puppet-0.25.4-1 on both > sides on centos 5.4. > > -----Original Message----- > From: Sukh Khehra > Sent: Wednesday, April 21, 2010 8:39 PM > To: ''puppet-users@googlegroups.com'' > Subject: variable interpolation weirdness > > Can someone please explain what''s happening here? Let me know if you > need more info. Thanks in advance for your time. > > I have a module called abc. This is the init.pp for that module. > > > ################### > $ cat modules/production/abc/manifests/init.pp > # Puppet Module: abc > # > > class abc { > package { "maatkit": ensure => present } > } > > class abc::base inherits abc { > exec { "testvars": command => "/bin/echo > ''java_version=${java_version}''", logoutput => true; } > } > > class abc::test { > $java_version = "jdk1.6.0_14" > include abc::base > } > ################### > > > I accidently assigned both the "abc" and "abc::test" class to a host and > noticed that the variable "java_version" no longer gets interpolated. > E.g. here''s the puppet run log. > > # puppetd -t > notice: Ignoring --listen on onetime run > info: Retrieving plugin > info: Caching catalog for abc1.staging.pp.com > info: Applying configuration version ''1271906581'' > notice: //abc::base/Exec[testvars]/returns: java_version> notice: //abc::base/Exec[testvars]/returns: executed successfully > warning: Value of ''preferred_serialization_format'' (pson) is invalid for > report, using default (marshal) > notice: Finished catalog run in 3.21 seconds > > Hi Sukh,Both classes are included but the $java_version is defined in a different scope than the include of abc on your node. node |--include "abc" <-- in this scope $java_version has not been defined |--include "abc::test" <- $java_version is defined |-- include "abc" <-- The variable affects this scope, but is already included, then not used again.> But If I only assign the host the "abc::test" class, everything works ok > like so: > > # puppetd -t > notice: Ignoring --listen on onetime run > info: Retrieving plugin > info: Caching catalog for abc1.staging.pp.com > info: Applying configuration version ''1271906581'' > notice: //abc::base/Exec[testvars]/returns: java_version=jdk1.6.0_14 > notice: //abc::base/Exec[testvars]/returns: executed successfully > warning: Value of ''preferred_serialization_format'' (pson) is invalid for > report, using default (marshal) > notice: Finished catalog run in 3.21 seconds > > In here the abc::test class defines the $java_version and when the abcclass is included(only one time) the exec prints the value of the variable that is in the same scope. Here you will find a detailed explanation of variable scope and inheritance. http://docs.puppetlabs.com/guides/troubleshooting.html#common_misconceptions Hope that helps.> > So I obviously know what to do to fix the problem but would love to > understand what''s happening here. > > Regards, > Sukh > > > > > -- > 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. > >-- Tony -- 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.