Luke, thanks for the reply.  So just to clarify, you can't even have a
child class append to an array declared in the parent class and have
it visible in the parent class?

Scott

On Jan 19, 9:44 pm, Luke Kanies <l...@madstop.com> wrote:
> On Jan 17, 2009, at 12:31 AM, Scott wrote:
>
>
>
>
>
> > So I need a variable in a child class to be visible to the parent
> > class and I'm wondering how I can do that?  The docs say "You will
> > almost always find that you can avoid resetting variable values using
> > the built in conditionals:" but I guess this is one of those cases
> > where it just isn't possible:
>
> > node default {}
>
> > node testserver inherits default {
> >  include testclasses                     <- (this is where I need
> > $var to be visible)
> > }
>
> > node test1.example.com inherits testserver {
> >  $var = "host server name"
> > }
>
> > As far as I can tell, there's no way to include another node,
> > otherwise I could have "test1.example.com" include "testserver"
> > instead of inheriting.  I can't set a variable in the parent class
> > from the child class because variables in puppet can only be set
> > once.  And, the way it is right now, exactly as it is above, $var
> > evaluates to nil because the $var declaration is out of the scope of
> > the parent class.
>
> > I don't want to include "testclasses" in "test1.example.com" because
> > then I'm going to have to include it for every individual "testserver"
> > node defeating the whole purpose of inheritance, cluttering up the
> > config files and making it easier to make mistakes.  So far, this is
> > the only way I've been able to get it to work but it's a kludge and
> > I'd prefer to avoid it.
>
> > I tried something like this as well:
>
> > node default {}
>
> > node testserver inherits default {
> >  $var = ["text1", "text2"]
> > }
>
> > node test1.example.com inherits testserver {
> >  $var += ["text3"]
> > }
>
> > but the parameter of the puppet type I'm trying to set with $var
> > (nagios_host: hostgroups) doesn't accept arrays.  So if a child class
> > can append to an array in a parent class, is there a way to get the
> > string version of an array with all the elements concatenated together
> > with a "," in between each element?  Either that or is there a way I
> > can get the "hostgroups" parameter in the "nagios_host" type to accept
> > arrays?
>
> > I feel like I've got to be missing something here.  Thanks.
>
> The only real way to do this is to use an external nodes tool.  I've  
> attached a simple script that serves node infromation out of YAML  
> files; it isn't awesome but it'll do what you want, anyway.
>
> --
> All power corrupts, but we need the electricity.
>      -- Unknown
> ---------------------------------------------------------------------
> Luke Kanies |http://reductivelabs.com|http://madstop.com
>
>  external_nodes.rb
> 1KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to