Here''s the problem I''m trying to solve. I use apache, for lots of things, some of those things are configured from a performance standpoint differently. In less vague terms I need to be able to change the MaxClients setting to different things based on the different purposes apache serves. (say proxy vs. app) Under previous CMS/templating engines I would have a httpd.conf that was applicable for both cases and then I would variablize MaxClients and set the appropriate value for the proxy vs the app. I was thinking to do the same thing in puppet: # default apache setup class apache { $maxclients = "200" file { "/etc/httpd/conf/httpd.conf": content => template("httpd.conf", ... } } class apache::proxy includes apache { $maxclients = "1000" } class apache::app includes apache { $maxclients = "25" } Apparently doing it this way causes the content of httpd.conf to only get the base apache value, even though in the other classes it''s set correctly. I''m sure partly I''m not groking scope (it''s late here), but what''s the right way for me to do this. My current alternative is to drop a conf.d/worker.conf with those settings in it and just let them override httpd.conf C -- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Chris MacLeod wrote:> Here''s the problem I''m trying to solve. > I use apache, for lots of things, some of those things are configured from a > performance standpoint differently. > In less vague terms I need to be able to change the MaxClients setting to > different things based on the different purposes apache serves. (say proxy > vs. app) > > Under previous CMS/templating engines I would have a httpd.conf that was > applicable for both cases and then I would variablize MaxClients and set the > appropriate value for the proxy vs the app. > > I was thinking to do the same thing in puppet: > > # default apache setup > class apache { > $maxclients = "200" > file { "/etc/httpd/conf/httpd.conf": > content => template("httpd.conf", > ... > } > } > > class apache::proxy includes apache { > $maxclients = "1000" > } > > class apache::app includes apache { > $maxclients = "25" > } > > Apparently doing it this way causes the content of httpd.conf to only get > the base apache value, even though in the other classes it''s set correctly. > > I''m sure partly I''m not groking scope (it''s late here), but what''s the right > way for me to do this. My current alternative is to drop a conf.d/worker.conf > with those settings in it and just let them override httpd.conf >I assume that you meant inherits apache in your example above. Variables are immutable, and there really isn''t a separate scope in the subclasses. When you include apache::proxy, the parent class gets evaluated first. Then apache::proxy is evaluated. Since the value was already set in the parent, it can''t be overridden. This restriction doesn''t apply to resources which can be overridden. To get around this, you can either leave setting maxclients out the base apache class (which you don''t include in nodes) and only set it in the subclasses, or you can leave it out the classes altogether and set it the node definition before including the relevant class. Hope this helps. -- Russell A. Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield Save gas, don''t eat beans.
Chris MacLeod schrieb:> Here''s the problem I''m trying to solve. > > I use apache, for lots of things, some of those things are configured > from a performance standpoint differently. > In less vague terms I need to be able to change the MaxClients setting > to different things based on the different purposes apache serves. > (say proxy vs. app) > > Under previous CMS/templating engines I would have a httpd.conf that was > applicable for both cases and then I would variablize MaxClients and set > the appropriate value for the proxy vs the app. > > I was thinking to do the same thing in puppet: > > # default apache setup > class apache { > $maxclients = "200" > file { "/etc/httpd/conf/httpd.conf": > content => template(" httpd.conf", > ... > } > } > > class apache::proxy includes apache { > $maxclients = "1000" > } > > class apache::app includes apache { > $maxclients = "25" > } > > Apparently doing it this way causes the content of httpd.conf to only > get the base apache value, even though in the other classes it''s set > correctly. > > I''m sure partly I''m not groking scope (it''s late here), but what''s the > right way for me to do this. My current alternative is to drop a > conf.d/worker.conf with those settings in it and just let them override > httpd.confYes on both counts. Children''s scope is "below" the parent''s scope, thus cannot override variables there. The best way to do the workers.conf would be to have a define: define apache::max_clients($count = 200) { file { "/etc/apache2/conf.d/workers.conf": content => "MaxClients ${count}\n" } } _Then_ you can use overriding again: class apache { max_clients { crutch: count => 200 } ... } class app inherits apache {Max_clients[crutch] { count => 25 } } Regards, David
On Fri, Nov 09, 2007 at 12:04:53AM -0500, Chris MacLeod wrote:> Under previous CMS/templating engines I would have a httpd.conf that was > applicable for both cases and then I would variablize MaxClients and set the > appropriate value for the proxy vs the app. > > I was thinking to do the same thing in puppet: > > # default apache setup > class apache { > $maxclients = "200" > file { "/etc/httpd/conf/httpd.conf": > content => template("httpd.conf", > ... > } > } > > class apache::proxy includes apache { > $maxclients = "1000" > } > > class apache::app includes apache { > $maxclients = "25" > } > > Apparently doing it this way causes the content of httpd.conf to only get > the base apache value, even though in the other classes it''s set correctly. > > I''m sure partly I''m not groking scope (it''s late here), but what''s the right > way for me to do this. My current alternative is to drop a conf.d/worker.conf > with those settings in it and just let them override httpd.confDon''t try playing scope games, set the variables directly with a define: define apache($maxclients = 200) { file { "/etc/httpd/conf/httpd.conf": ... } } class apache::proxy { apache { proxy_apache: maxclients => 1000 } } class apache::app { apache { app_apache: maxclients => 25 } } - Matt -- Java. The elegant simplicity of C++. The blazing speed of Smalltalk. -- From http://c2.com/cgi/wiki?SmalltalkMinusMinus
David Schmitt wrote:> Chris MacLeod schrieb: >> Here''s the problem I''m trying to solve. >> >> I use apache, for lots of things, some of those things are configured >> from a performance standpoint differently. >> In less vague terms I need to be able to change the MaxClients setting >> to different things based on the different purposes apache serves. >> (say proxy vs. app) >> >> Under previous CMS/templating engines I would have a httpd.conf that was >> applicable for both cases and then I would variablize MaxClients and set >> the appropriate value for the proxy vs the app. >> >> I was thinking to do the same thing in puppet: >> >> # default apache setup >> class apache { >> $maxclients = "200" >> file { "/etc/httpd/conf/httpd.conf": >> content => template(" httpd.conf", >> ... >> } >> } >> >> class apache::proxy includes apache { >> $maxclients = "1000" >> } >> >> class apache::app includes apache { >> $maxclients = "25" >> } >> >> Apparently doing it this way causes the content of httpd.conf to only >> get the base apache value, even though in the other classes it''s set >> correctly. >> >> I''m sure partly I''m not groking scope (it''s late here), but what''s the >> right way for me to do this. My current alternative is to drop a >> conf.d/worker.conf with those settings in it and just let them override >> httpd.conf > > Yes on both counts. Children''s scope is "below" the parent''s scope, thus > cannot override variables there. The best way to do the workers.conf > would be to have a define: > > define apache::max_clients($count = 200) { > file { "/etc/apache2/conf.d/workers.conf": content => "MaxClients > ${count}\n" } > } > > _Then_ you can use overriding again: > > class apache { max_clients { crutch: count => 200 } ... } > class app inherits apache {Max_clients[crutch] { count => 25 } } >Parameterizing the template with a defined type this way probably is the better way to go. -- Russell A. Jackson <raj@csub.edu> Network Analyst California State University, Bakersfield Save gas, don''t eat beans.