On Monday, September 24, 2012 11:47:31 AM UTC-5, George Shammas wrote: > > I am trying to override variables in a class that is defined in the > default node profile. I want parent class to be included in every single > node, but override its variables in others. I have tried > it several different ways now, and every single time the variables either > become unset (undefined) or are set to the value of the first if statement.
You cannot override class variables. You especially cannot override class parameters. You can override only resource properties (and classes are not resources, appearances notwithstanding). Moreover, subclasses do not set parameters for their parent classes, even if they themselves have parameters of the same names. Therefore, it is usually a bad idea to inherit from a parametrized class (in fact, the v 2.7 docs say it's not supported). If you do so, then you must explicitly declare the parent class on every node for which you want to set non-default parameters, whether or not you also declare the child class. Since you don't actually use the variables in question in your example, I can't guess what your larger purpose may be, therefore it is difficult for me to advise you. Nevertheless, at the low level we are focused on, you can achieve something similar to what you have asked by employing a data hierarchy instead of a class hierarchy. That is what the Hiera module is all about. Since hiera will be integrated into Puppet 3, getting started with it now is also forward-looking. Once you install hiera and set up your data, the Puppet side could be as simple as this: class nrpe::load { # no parameters package { 'nagios-plugins-load': ensure => installed } $warn_real = hiera('nrpe::warn') $crit_real = hiera('nrpe::crit') # alternatively, load $warn and $crit via hiera, # and retain the original logic for setting # $warn_real and $crit_real file { "/etc/nagios/command.d/load.cfg": owner => root, group => root, mode => 640, content => template("nrpe/load.cfg.erb"), notify => Service[nrpe] } } node "somenode.tld" inherits basenode { # no subclass involved } John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/UeqNuH8zyXMJ. 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.