Sometimes things just have to happen in sequence. It is the simplest of relations, but puppet really has no convenient, non-fiddly way to express it. So, how about class x { order { "z": file { "a": ... } exec { "b": ... ; "c": ... ; "d": ... ; "e": ... ; } } } Things inside order { } happen in the order that they appear. They implicitly have before dependency assigned according to their position. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I take it you''re not familiar with the `requires'' parameter. On Mon, Jul 4, 2011 at 8:40 PM, vagn scott <vagnscott@gmail.com> wrote:> Sometimes things just have to happen in sequence. > It is the simplest of relations, but puppet really > has no convenient, non-fiddly way to express it. > So, how about > > > class x { > > order { "z": > > file { "a": > ... > } > > exec { > "b": ... ; > "c": ... ; > "d": ... ; > "e": ... ; > } > } > > } > > Things inside order { } happen in the order > that they appear. They implicitly have before > dependency assigned according to their position. > > -- > 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+unsubscribe@** > googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/04/2011 11:42 PM, Scott Smith wrote:> I take it you''re not familiar with the `requires'' parameter.I''m familiar with requires subscribe notifies -> <- before which are great for specifying relations between non-adjacent things. But they are annoying to use for resources close together in a text file. It just reads like noise. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ignoring the fact that "noise" is very subjective... it doesn''t. In Puppet, position in a file has no bearing on order. It''s not an imperative language. On Mon, Jul 4, 2011 at 8:46 PM, vagn scott <vagnscott@gmail.com> wrote:> On 07/04/2011 11:42 PM, Scott Smith wrote: > >> I take it you''re not familiar with the `requires'' parameter. >> > > I''m familiar with > > requires > subscribe > notifies > -> > <- > before > > which are great for specifying relations between non-adjacent things. > But they are annoying to use for resources close together in a text file. > It just reads like noise. > > > > -- > 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+unsubscribe@** > googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/04/2011 11:51 PM, Scott Smith wrote:> Ignoring the fact that "noise" is very subjective... it doesn''t. In > Puppet, position in a file has no bearing on order. It''s not an > imperative language.I understand. What I am saying is that another way to express this file { "a": path => " aaa ", before => Exec[ "b" ], } exec { "b": command => "bbb", before => File[ "c" ], } file { "c": path => " ccc ", before => Exec[ "d" ], } would be this: order { file { "aaa": } exec { "bbb": } file { "ccc": } } -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/04/2011 11:56 PM, vagn scott wrote:> On 07/04/2011 11:51 PM, Scott Smith wrote: >> Ignoring the fact that "noise" is very subjective... it doesn''t. In >> Puppet, position in a file has no bearing on order. It''s not an >> imperative language. >Oops, that should be: file { "a": path => " aaa ", before => Exec[ "b" ], } exec { "b": command => "bbb", before => File[ "c" ], } file { "c": path => " ccc ", } same as: order { "z": file { "aaa": } exec { "bbb": } file { "ccc": } } With the added benefit that you could do Order[ "z" ] -> Something[ "foo" ] -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thinking about this some more, I like block better, with order optional: class c { block { "x": # any order package { ... } file { "aaa": } exec { "bbb": } file { "ccc": } include foo } block { "y": # order matters $ordered => true # default is false file { "ddd": } exec { "eee": } include baz file { "fff": } } block { "z": # any order file { "ggg": } exec { "hhh": } file { "iii": } } Block[ x ] -> Block[ y ] -> Block[ z ] } meaning all in x before any in y, then y in sequence, before any in z -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Whatever problem you are trying to solve is most likely best handled outside of Puppet. On Mon, Jul 4, 2011 at 9:59 PM, vagn scott <vagnscott@gmail.com> wrote:> Thinking about this some more, I like block better, > with order optional: > > class c { > > block { "x": # any order > package { ... } > > file { "aaa": } > exec { "bbb": } > file { "ccc": } > include foo > } > block { "y": # order matters > $ordered => true # default is false > file { "ddd": } > exec { "eee": } > include baz > file { "fff": } > } > block { "z": # any order > file { "ggg": } > exec { "hhh": } > file { "iii": } > } > > Block[ x ] -> Block[ y ] -> Block[ z ] > > } > > meaning all in x before any in y, then y in sequence, > before any in z > > > -- > 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+unsubscribe@** > googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/05/2011 01:08 AM, Scott Smith wrote:> Whatever problem you are trying to solve is most likely best handled > outside of Puppet.The problem I''m trying to solve is one of expressiveness in the language. I''m not adding any functionality that is not already in puppet. I''m just suggesting there are better (more readable, less tedious) ways to express it. -- vagn -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This> file { "a": > path => " aaa ", > before => Exec[ "b" ], > } > > exec { "b": > command => "bbb", > before => File[ "c" ], > } > > file { "c": > path => " ccc ", > before => Exec[ "d" ], > }Can also be: file { "a": path => " aaa ", } exec { "b": command => "bbb", } file { "c": path => " ccc ", } File[''a''] -> Exec[''b''] -> File[''c''] ~pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk4Sp60ACgkQbwltcAfKi39UGwCeLzGDvKifM4wojlomy7O0idmo i5IAni52e3YvE8pWdRf8Ide8vLcZPkl0 =NSLF -----END PGP SIGNATURE----- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/05/2011 01:57 AM, Peter Meier wrote:> Can also be: > >Yes, I know. Now expand this one, and maybe you will get my point. ----------------- Thinking about this some more, I like block better, with order optional: class c { block { "x": # any order package { ... } file { "aaa": } exec { "bbb": } file { "ccc": } include foo } block { "y": # order matters $ordered => true # default is false file { "ddd": } exec { "eee": } include baz file { "fff": } } block { "z": # any order file { "ggg": } exec { "hhh": } file { "iii": } } Block[ x ] -> Block[ y ] -> Block[ z ] } meaning all in x before any in y, then y in sequence, before any in z -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I like it. You could also call the class like we do with stages: class { c: ordered => strict, stage => main } This could influence the way block[x] -> block[y] is called. It would make determining order and troubleshooting clearer. Anyway, put up a feature request and I''ll vote for it. Cheers, Den On 05/07/2011, at 17:03, vagn scott <vagnscott@gmail.com> wrote:> On 07/05/2011 01:57 AM, Peter Meier wrote: >> Can also be: >> >> > Yes, I know. Now expand this one, and maybe you will get my point. > > ----------------- > > Thinking about this some more, I like block better, > with order optional: > > class c { > > block { "x": # any order > package { ... } > file { "aaa": } > exec { "bbb": } > file { "ccc": } > include foo > } > block { "y": # order matters > $ordered => true # default is false > file { "ddd": } > exec { "eee": } > include baz > file { "fff": } > } > block { "z": # any order > file { "ggg": } > exec { "hhh": } > file { "iii": } > } > > Block[ x ] -> Block[ y ] -> Block[ z ] > > } > > meaning all in x before any in y, then y in sequence, > before any in z > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Whats wrong with using chained resources? class x { file { "a": } -> exec { "b": } -> exec { "c": } -> exec { "d": } } ken. On Tue, Jul 5, 2011 at 4:40 AM, vagn scott <vagnscott@gmail.com> wrote:> Sometimes things just have to happen in sequence. > It is the simplest of relations, but puppet really > has no convenient, non-fiddly way to express it. > So, how about > > > class x { > > order { "z": > > file { "a": > ... > } > > exec { > "b": ... ; > "c": ... ; > "d": ... ; > "e": ... ; > } > } > > } > > Things inside order { } happen in the order > that they appear. They implicitly have before > dependency assigned according to their position. > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I wasn''t aware of that layout of the syntax, that''s a really interesting way of writing it. The OP would seem to want "blocks" added to this though. This is all very reminiscent of Stages though, so surely if there IS a solution that satisfies the original need it would be an adjustment to stages. Maybe more dynamic substages... main.a, main.b or something as actually different stages would cause all sorts of mess if treated this glibly. If it were possible to run multiple stages within a single class (you can''t, right?) then that''d nearly be the solution already. Chris On 5 July 2011 09:35, Ken Barber <ken@puppetlabs.com> wrote:> Whats wrong with using chained resources? > > class x { > file { "a": > } -> > exec { "b": > } -> > exec { "c": > } -> > exec { "d": > } > } > > ken. > > On Tue, Jul 5, 2011 at 4:40 AM, vagn scott <vagnscott@gmail.com> wrote: > > Sometimes things just have to happen in sequence. > > It is the simplest of relations, but puppet really > > has no convenient, non-fiddly way to express it. > > So, how about > > > > > > class x { > > > > order { "z": > > > > file { "a": > > ... > > } > > > > exec { > > "b": ... ; > > "c": ... ; > > "d": ... ; > > "e": ... ; > > } > > } > > > > } > > > > Things inside order { } happen in the order > > that they appear. They implicitly have before > > dependency assigned according to their position. > > > > -- > > 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+unsubscribe@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/05/2011 04:35 AM, Ken Barber wrote:> Whats wrong with using chained resources? >It doesn''t scale. Try expanding this (it is a slightly improved proposal with block{} instead of order{}): class c { block { "x": # any order package { ... } file { "aaa": } exec { "bbb": } file { "ccc": } include foo } block { "y": # order matters $ordered => true # default is false file { "ddd": } exec { "eee": } include baz file { "fff": } } block { "z": # any order file { "ggg": } exec { "hhh": } file { "iii": } } Block[ x ] -> Block[ y ] -> Block[ z ] } meaning all resources in x before any in y, then y in sequence, before any in z ------------ Now, you can rewrite this using class {} instead of block{}. You probably have lots of classes in that style, and then you sequence things with Class[ a ] -> Class[ b ]. How many of those classes only exist because there is no other block structure? I submit that if you make a class, it should be sensible to include it somewhere, as a class, representing something useful. We need blocks so we don''t go around abusing classes. -- vagn -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jul 5, 10:26 am, vagn scott <vagnsc...@gmail.com> wrote:> Now, you can rewrite this using class {} instead of block{}. > You probably have lots of classes in that style, and then you > sequence things with Class[ a ] -> Class[ b ]. How many of > those classes only exist because there is no other block structure? > > I submit that if you make a class, it should be sensible to include > it somewhere, as a class, representing something useful. > We need blocks so we don''t go around abusing classes. > > -- > vagnExcuse the fuel for the fire... A class in Puppet is just a group of objects that have some sort of relationship - whether people are abusing classes or not depends on one''s point of view. The choice of the word "class" has been lamented over before ;) To be honest I don''t see much benefit in a block{} structure, I just see it as avoiding the use of a class for people''s conceptual reasons. -Luke -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/05/2011 05:35 AM, Luke Bigum wrote:> avoiding the use of a class for ... > conceptual reasons. > >Exactly right. Thank you for that phrase. -v -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Well ... then I agree with your sentiments on using classes, it can get ugly using inner classes to achieve what you want. Something I often find myself doing with the puppetlabs-firewall module using inner classes to get around having to do proto => tcp and proto => udp repeatedly: class c { class ipt_t { Firewall { proto => tcp, jump => "ACCEPT" } firewall { "100 accept ssh": dport => 22 } # ... more tcp rules ... } include ipt_t class ipt_u { Firewall { proto => udp, jump => "ACCEPT" } firewall { "100 accept dns": dport => 53 } # ... more udp rules ... } include ipt_u } Perhaps anonymous blocks/closures are a more flexible proposal for the language which solves both problems? For example: class c { { # Order matters package { "a": }-> exec { "b": } }-> { # Order doesn''t matter package { "b": } exec { "c": } } } Then you can also use these anonymous blocks/closures with defaults as well: class c { { Service { hasstatus => true } service { "a": } }-> { Service { hasstatus => false } service { "b": } } } ken. On Tue, Jul 5, 2011 at 10:26 AM, vagn scott <vagnscott@gmail.com> wrote:> On 07/05/2011 04:35 AM, Ken Barber wrote: >> >> Whats wrong with using chained resources? >> > > It doesn''t scale. > > Try expanding this (it is a slightly improved > proposal with block{} instead of order{}): > > class c { > > block { "x": # any order > package { ... } > file { "aaa": } > exec { "bbb": } > file { "ccc": } > include foo > } > block { "y": # order matters > $ordered => true # default is false > file { "ddd": } > exec { "eee": } > include baz > file { "fff": } > } > block { "z": # any order > file { "ggg": } > exec { "hhh": } > file { "iii": } > } > > Block[ x ] -> Block[ y ] -> Block[ z ] > > } > > meaning all resources in x before any in y, then y in sequence, > before any in z > > ------------ > > Now, you can rewrite this using class {} instead of block{}. > You probably have lots of classes in that style, and then you > sequence things with Class[ a ] -> Class[ b ]. How many of > those classes only exist because there is no other block structure? > > I submit that if you make a class, it should be sensible to include > it somewhere, as a class, representing something useful. > We need blocks so we don''t go around abusing classes. > > -- > vagn > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 07/05/2011 05:51 AM, Ken Barber wrote:> Then you can also use these anonymous blocks/closures with defaults as well: > > class c { > { > Service { hasstatus => true } > service { "a": } > }-> >Yes, they should have their own scope, and pretty normal puppet semantics/conventions. Maybe the only thing that sets them apart from regular classes is that you cannot include them anywhere. That, and I would like to see an $ordered = true|false meta parameter. I think they should be optionally named, though, so they can be mentioned in relationships. we could have both block { "a": ... } and just the anonymous { ... } -- vagn -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.