I was wondering if there was an elegant way to extend a require array. To whit it would be wonderful to do somthing like this: class one { service { awesome: require => [ File[one], File[two] ] } file { one: ... two: ... } } class two inherits one { Service[awesome] { Require => + [ File[three], File[four] ] } file { three: ... four: ... } } The idea being that class one is the base class for more than just class two and there is a shared set of dependencies in class one that class two needs to inherit and append to. --Robert
Robert Nickel
2007-Jun-12 23:01 UTC
Re: Extending existing require arrays in classes [WAS: test]...
Sorry about the subject line. I was distracted when writing the first part of the message. --Robert
On Jun 12, 2007, at 5:29 PM, Robert Nickel wrote:> > class two inherits one { > Service[awesome] { Require => + [ File[three], File[four] ] }[...]> The idea being that class one is the base class for more than just > class two > and there is a shared set of dependencies in class one that class > two needs to > inherit and append to.I''ve often envisioned this, although with this syntax: require +> [File[three], File[four]] I have floated it once or twice to not-exactly-stellar reviews. It should be pretty easy to add, and would be a great starter project for someone looking to contribute; it''d be restricted almost entirely to the parser. -- The hypothalamus is one of the most important parts of the brain, involved in many kinds of motivation, among other functions. The hypothalamus controls the "Four F''s": 1. fighting; 2. fleeing; 3. feeding; and 4. mating. -- Psychology professor in neuropsychology intro course --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
I can say there are a number of things I''ve been thinking of using puppet for that this would greatly simplify. For example I have a very simplistic firewall define that takes an array of ports, I''d love to be able to simply extend the ports when doing inheritance rather than redefining the whole array. Thanks Brian On 6/12/07, Luke Kanies <luke@madstop.com> wrote:> On Jun 12, 2007, at 5:29 PM, Robert Nickel wrote: > > > > class two inherits one { > > Service[awesome] { Require => + [ File[three], File[four] ] } > [...] > > The idea being that class one is the base class for more than just > > class two > > and there is a shared set of dependencies in class one that class > > two needs to > > inherit and append to. > > I''ve often envisioned this, although with this syntax: > > require +> [File[three], File[four]] > > I have floated it once or twice to not-exactly-stellar reviews. > > It should be pretty easy to add, and would be a great starter project > for someone looking to contribute; it''d be restricted almost entirely > to the parser. > > -- > The hypothalamus is one of the most important parts of the brain, > involved in many kinds of motivation, among other functions. The > hypothalamus controls the "Four F''s": 1. fighting; 2. fleeing; > 3. feeding; and 4. mating. > -- Psychology professor in neuropsychology intro > course > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >
On Tue, 2007-06-12 at 18:25 -0500, Luke Kanies wrote:> I''ve often envisioned this, although with this syntax: > > require +> [File[three], File[four]]It would be a great feature to have. The only bone I have with it is the syntax: the immediately following feature request will be ''how do I remove something from an array'' ? I think using ''->'' there is a little odd. That would make using ''+='' and ''-='' more natural, but then ''=>'' should become ''='' ... Sorry, I don''t mean to start a flamewar (we did that already ;), but I believe that if you have the ability to extend arrays, you should also be able to remove elements from them (e.g., to have fewer ports on the firewall open) David
On Jun 15, 2007, at 11:19 PM, David Lutterkort wrote:> On Tue, 2007-06-12 at 18:25 -0500, Luke Kanies wrote: >> I''ve often envisioned this, although with this syntax: >> >> require +> [File[three], File[four]] > > It would be a great feature to have. The only bone I have with it > is the > syntax: the immediately following feature request will be ''how do I > remove something from an array'' ? I think using ''->'' there is a little > odd. That would make using ''+='' and ''-='' more natural, but then ''=>'' > should become ''='' ... > > Sorry, I don''t mean to start a flamewar (we did that already ;), but I > believe that if you have the ability to extend arrays, you should also > be able to remove elements from them (e.g., to have fewer ports on the > firewall open)"Should" and "can" are completely different. I have a very simple pretty good syntax for adding to arrays, and I can easily see both the reasons for using it and how to implement it. On the other hand, I do not nearly so clearly see a good syntax for removing from arrays, nor do I see good semantics around it. Really, removing something from an array generally requires knowing exactly what''s in that array, which means that to provide this functionality we have to provide a bunch more. With array addition, though, all you need to know is that you want this value added to the list, which doesn''t require any such understanding. This "add to" syntax is mere hours of work, IMO, but any other syntaxes are probably days of work. -- The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly goes wrong goes wrong it usually turns out to be impossible to get at or repair. -- Douglas Adams, Mostly Harmless --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com