"Service and class definitions are scoped just as variable assignments are." But what about types? Here''s an example: class solserver inherits server { remotefile { "/etc/shadow": mode => 400, group => staff, source => "solall/etc/shadow.server" } Is it possible to just override the "/etc/shadow" definition for some nodes? It certainly doesn''t work to just redefine the remotefile["/etc/shadow"]. This is complicated to explain, but in the end, these special nodes do inherit solserver, and then include their own class (where I''d like to override the file "/etc/shadow" and some other things). What''s the best way to do this? There are only 5 one-offs in this case, so maybe I should just use a selector for "source" to check $hostname within the solserver class? If so, can I use multiple hostnames as a selector, like this: remotefile { "/etc/shadow": source = $hostname ? { myhost1, myhost2, myhost3 => "path/a", default => "path/b" } } In short, is there a way to override "types" without putting them in seperate classes? There are times where I want to override, but still want to include a class that defines the same thing. Being able to override things like this would dramatically reduce complexity, in that I won''t have to include a big list of classes if I can just include a common parent. Holy crap this doesn''t make any sense.. I hope someone can parse what I''m *trying* to say :) -Charlie
On Dec 21, 2006, at 2:51 PM, Charlie Schluting wrote:> "Service and class definitions are scoped just as variable > assignments are." > > But what about types? > > Here''s an example: > class solserver inherits server { > remotefile { "/etc/shadow": > mode => 400, group => staff, > source => "solall/etc/shadow.server" > } > > Is it possible to just override the "/etc/shadow" definition for some > nodes? It certainly doesn''t work to just redefine the > remotefile["/etc/shadow"].You should be able to override it like anything else: Remotefile["/etc/shadow"] { mode => 600 } -- I worry that the person who thought up Muzak may be thinking up something else. --Lily Tomlin --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On 12/21/06, Luke Kanies <luke@madstop.com> wrote:> > You should be able to override it like anything else: > > Remotefile["/etc/shadow"] { mode => 600 } >Could not retrieve configuration: Duplicate definition: file[/etc/passwd] is already defined in file /etc/puppet/manifests/solaris.pp at line 7; cannot redefine in file /etc/puppet/manifests/solaris.pp at line 53 That''s the result of a test I did, which prompted the question. Note that line 7 and line 53 are in different classes, but 53 inherits 7. -Charlie
On Dec 21, 2006, at 3:09 PM, Charlie Schluting wrote:> Could not retrieve configuration: Duplicate definition: > file[/etc/passwd] is already defined in file > /etc/puppet/manifests/solaris.pp at line 7; cannot redefine in file > /etc/puppet/manifests/solaris.pp at line 53 > > That''s the result of a test I did, which prompted the question. Note > that line 7 and line 53 are in different classes, but 53 inherits 7.Can you please open that as a bug with a complete example that shows the failure? -- Nonreciprocal Laws of Expectations: Negative expectations yield negative results. Positive expectations yield negative results. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On 12/21/06, Luke Kanies <luke@madstop.com> wrote:> On Dec 21, 2006, at 3:09 PM, Charlie Schluting wrote: > > Could not retrieve configuration: Duplicate definition: > > file[/etc/passwd] is already defined in file > > /etc/puppet/manifests/solaris.pp at line 7; cannot redefine in file > > /etc/puppet/manifests/solaris.pp at line 53 > > > > That''s the result of a test I did, which prompted the question. Note > > that line 7 and line 53 are in different classes, but 53 inherits 7. > > Can you please open that as a bug with a complete example that shows > the failure?Uhm, oops. I''m not actually inheriting the class where the file is defined. That''s the problem. The class is applied to the node, but not directly inherited. This is going to be interesting. Has a need for multiple inheritance ever been brought up? :) Thanks for the help, Luke. I''m going to have to rethink my structure (or use a selector). -Charlie
Well I thought I had it figured out; this is driving me a bit crazy now :) Can you confirm that you cannot override things unless you actually inherit, as opposed to including? My real example looks something like this: node A inherits solaris { include host_A } class host_A inherits solserver { remotefile { "/etc/group": mode => 644, group => other, source => "solall/etc/group.A" } } class solserver inherits server { remotefile { "/etc/group": mode => 644, group => other, source => "solall/etc/group.server" } } class server { } #Currently empty With that I get: remotefile[/etc/group] is already defined in file /etc/puppet/manifests/server.pp ... which is expected? I''m also trying to override something in the solaris class, which is why I had my host_A class inherit solaris. But I can''t also inherit/override something in solserver, huh? Thanks, -Charlie
On Thu, 2006-12-21 at 16:32 -0800, Charlie Schluting wrote:> Well I thought I had it figured out; this is driving me a bit crazy now :) > > Can you confirm that you cannot override things unless you actually > inherit, as opposed to including?That is correct.> My real example looks something like this: > > node A inherits solaris { > include host_A > } > class host_A inherits solserver { > remotefile { "/etc/group": > mode => 644, group => other, > source => "solall/etc/group.A" > } > } > class solserver inherits server { > remotefile { "/etc/group": > mode => 644, group => other, > source => "solall/etc/group.server" > } > } > class server { } #Currently empty > > With that I get: > remotefile[/etc/group] is already defined in file > /etc/puppet/manifests/server.ppThe problem is that your class host_A should read class host_A inherits solserver { Remotefile["/etc/group"] { mode => 644, group => other, source => "solall/etc/group.A" } } Since (I think) puppet 0.20.0 overrides have a different syntax from new definitions: new definitions use ''type { name: attr => value }'' whereas overrides use ''Type[name] { attr => value }''> ... which is expected? I''m also trying to override something in the > solaris class, which is why I had my host_A class inherit solaris. But > I can''t also inherit/override something in solserver, huh?With the change above, thonly fly in the ointment is that I don''t think that nodes can inherit from classes (unless that has changed recently) David
On 12/21/06, David Lutterkort <dlutter@redhat.com> wrote:> On Thu, 2006-12-21 at 16:32 -0800, Charlie Schluting wrote: > > Can you confirm that you cannot override things unless you actually > > inherit, as opposed to including? > > That is correct.Good, that''s what I thought.> Since (I think) puppet 0.20.0 overrides have a different syntax from new > definitions: new definitions use ''type { name: attr => value }'' whereas > overrides use ''Type[name] { attr => value }''I completely missed that in the documentation. With these changes, and my reorganization, it''s working now.> > With the change above, thonly fly in the ointment is that I don''t think > that nodes can inherit from classes (unless that has changed recently)I don''t know what I was trying to do there. That''s been fixed too :) Thanks! -Charlie