Re: [Puppet Users] Style (syntax?) question

2018-06-06 Thread Arnau
2018-06-06 14:30 GMT+02:00 jcbollinger :

>
>
> On Tuesday, June 5, 2018 at 9:00:47 AM UTC-5, Arnau wrote:
>
>
>> ( fun fact: https://groups.google.com/forum/#!topic/puppet-users/T1cIUuK
>> BU0E isn't this you using "Class"? or am I missing something?
>>
>
> Sure is.  But those are (valid) resource / class references (
> Class['someclass']),  not the invalid mutant form appearing in the OP's
> example (Class { 'somclass': }).  Note differences in bracketing and
> presence vs absence of a colon.
>

You're totally right... I think my brain did reformat the OP message :-)
Now I see that even the second line is totally wrong:

 -> class('someclass::configure':}# right... <- Opening with a
parenthesis closing with a bracket...
 -> Class{'someclass':}


>
> John
>
>
Sorry for the noise,
Arnau

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAM69jx-_JKPU1sQZjeaunm0%3DbU0gQgnh7J9QVw8YARCRNZE7oQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-06 Thread jcbollinger


On Tuesday, June 5, 2018 at 9:00:47 AM UTC-5, Arnau wrote:
 

> ( fun fact: 
> https://groups.google.com/forum/#!topic/puppet-users/T1cIUuKBU0E isn't 
> this you using "Class"? or am I missing something?
>

Sure is.  But those are (valid) resource / class references (
Class['someclass']),  not the invalid mutant form appearing in the OP's 
example (Class { 'somclass': }).  Note differences in bracketing and 
presence vs absence of a colon.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/b0f8b930-0060-4df2-92df-ef44fc7abd13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-05 Thread Ramin K

On 6/5/2018 6:01 AM, jcbollinger wrote:



On Monday, June 4, 2018 at 1:06:52 PM UTC-5, Ramin K wrote:

On 6/4/18 8:25 AM, Peter Berghold wrote:
 > I was looking at someone else's code one day last week and saw a
pattern
 > I've not seen before. Maybe that's what I get for developing
Puppet code
 > in a vacuum. :-)
 >
 > class someclass (
 >      $parm1 = $::someclass::params::parm1,
 >      $parm2 = $::someclass::params::parm2       # so far I get it.
 > ) inherits someclass::params {             # ok, I get it
 >
 >       class{'someclass::package': }        # OK
 >       -> class('someclass::configure':}    # right...
 >       -> Class{'someclass':}                    #  HUH?  What
does that do?
 > }
 >
 > Is that last step necessary and why?


The last step was fairly common in Puppet 2.7 code before Anchors.



Are you sure about that, Ramin?  I've been around Puppet since well 
before v2.7, and to the best of my knowledge, Class{'someclass':} (with 
capital 'C') is and always has been syntactically invalid.  I'm prepared 
to learn something new today, but you'll need to point me to some docs 
to support your assertion.


Myself, I'm inclined to guess that it's a simple typo, that an ordinary 
resource-style class declaration (with lowercase 'c') is what was intended.


"I was looking at someone else's code one day last week and saw a 
pattern I've not seen before." seems clear enough to me. Was pseudo code 
and I didn't think to look at the syntax. Jumped straight to the 
confusing part, a resource chain that ends on the class. I've answered 
the same question several times in support of our Puppet system at work. 
And then moved the module to contain... which generated more questions 
about include vs require vs contain. No winning some days.


Ramin

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/850a1e8d-58ab-7186-878d-9ef32f8d4e6c%40badapple.net.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-05 Thread Arnau
2018-06-05 15:01 GMT+02:00 jcbollinger :

>
>
> On Monday, June 4, 2018 at 1:06:52 PM UTC-5, Ramin K wrote:
>>
>> On 6/4/18 8:25 AM, Peter Berghold wrote:
>> > I was looking at someone else's code one day last week and saw a
>> pattern
>> > I've not seen before. Maybe that's what I get for developing Puppet
>> code
>> > in a vacuum. :-)
>> >
>> > class someclass (
>> >  $parm1 = $::someclass::params::parm1,
>> >  $parm2 = $::someclass::params::parm2   # so far I get it.
>> > ) inherits someclass::params { # ok, I get it
>> >
>> >   class{'someclass::package': }# OK
>> >   -> class('someclass::configure':}# right...
>> >   -> Class{'someclass':}#  HUH?  What does that
>> do?
>> > }
>> >
>> > Is that last step necessary and why?
>>
>>
>> The last step was fairly common in Puppet 2.7 code before Anchors.
>
>
>
> Are you sure about that, Ramin?  I've been around Puppet since well before
> v2.7, and to the best of my knowledge, Class{'someclass':} (with capital
> 'C') is and always has been syntactically invalid.  I'm prepared to learn
> something new today, but you'll need to point me to some docs to support
> your assertion.
>

I've been using that syntax in 3.8 for a long time:

  contain ::soge::install
  contain ::soge::configure
  contain ::soge::service

  Class ['::soge::install'] ->
  Class ['::soge::configure'] ~>
  Class ['::soge::service']

Maybe this ->
https://blog.mayflower.de/4573-The-Puppet-Anchor-Pattern-in-Practice.html

I remeber start using it when the contain function was released...

( fun fact: https://groups.google.com/forum/#!topic/puppet-users/T1cIUuKBU0E
isn't this you using "Class"? or am I missing something?

Best,
Arnau


>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAM69jx8ne4QP9mHaGO59Bz7iTWhBATnjrLtER7Cj5xXPc8hvmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-05 Thread R.I.Pienaar



On Tue, 5 Jun 2018, at 15:01, jcbollinger wrote:
> 
> 
> On Monday, June 4, 2018 at 1:06:52 PM UTC-5, Ramin K wrote:
> >
> > On 6/4/18 8:25 AM, Peter Berghold wrote: 
> > > I was looking at someone else's code one day last week and saw a pattern 
> > > I've not seen before. Maybe that's what I get for developing Puppet code 
> > > in a vacuum. :-) 
> > > 
> > > class someclass ( 
> > >  $parm1 = $::someclass::params::parm1, 
> > >  $parm2 = $::someclass::params::parm2   # so far I get it. 
> > > ) inherits someclass::params { # ok, I get it 
> > > 
> > >   class{'someclass::package': }# OK 
> > >   -> class('someclass::configure':}# right... 
> > >   -> Class{'someclass':}#  HUH?  What does that 
> > do? 
> > > } 
> > > 
> > > Is that last step necessary and why? 
> >
> >
> > The last step was fairly common in Puppet 2.7 code before Anchors.
> 
> 
> 
> Are you sure about that, Ramin?  I've been around Puppet since well before 
> v2.7, and to the best of my knowledge, Class{'someclass':} (with capital 
> 'C') is and always has been syntactically invalid.  I'm prepared to learn 
> something new today, but you'll need to point me to some docs to support 
> your assertion.
> 
> Myself, I'm inclined to guess that it's a simple typo, that an ordinary 
> resource-style class declaration (with lowercase 'c') is what was intended.
> 

class{'someclass::package': } 
-> class('someclass::configure':}
-> Class["someclass"] # or -> Class[$name]

Is the correct version of this.  It's a "soft" version of the anchor pattern, 
because:

   package{"foo": require => Class["someclass"]}

will have the inner classes completed before it without any crazy extra 
resources and stuff and it handles the case most people actually care for - but 
this is not a full contained class like contain() makes, you should probably 
use contain() today.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1528204221.2225351.1397064328.7404B769%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-05 Thread jcbollinger


On Monday, June 4, 2018 at 1:06:52 PM UTC-5, Ramin K wrote:
>
> On 6/4/18 8:25 AM, Peter Berghold wrote: 
> > I was looking at someone else's code one day last week and saw a pattern 
> > I've not seen before. Maybe that's what I get for developing Puppet code 
> > in a vacuum. :-) 
> > 
> > class someclass ( 
> >  $parm1 = $::someclass::params::parm1, 
> >  $parm2 = $::someclass::params::parm2   # so far I get it. 
> > ) inherits someclass::params { # ok, I get it 
> > 
> >   class{'someclass::package': }# OK 
> >   -> class('someclass::configure':}# right... 
> >   -> Class{'someclass':}#  HUH?  What does that 
> do? 
> > } 
> > 
> > Is that last step necessary and why? 
>
>
> The last step was fairly common in Puppet 2.7 code before Anchors.



Are you sure about that, Ramin?  I've been around Puppet since well before 
v2.7, and to the best of my knowledge, Class{'someclass':} (with capital 
'C') is and always has been syntactically invalid.  I'm prepared to learn 
something new today, but you'll need to point me to some docs to support 
your assertion.

Myself, I'm inclined to guess that it's a simple typo, that an ordinary 
resource-style class declaration (with lowercase 'c') is what was intended.

 

> [...]
>
>  

> By adding that -> Class{'someclass':} to the end you create a chain that 
> requires all classes to completed before 'someclass' is completed.
>


I don't think it's the chain operators that have Salty confused.  He says 
he's ok with a previous line that also uses one.  I'd be confused, too, if 
someone demonstrated that example code to compile successfully.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/2afa8ebb-0357-47a7-9256-1478b65c5e35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Style (syntax?) question

2018-06-04 Thread Ramin K

On 6/4/18 8:25 AM, Peter Berghold wrote:
I was looking at someone else's code one day last week and saw a pattern 
I've not seen before. Maybe that's what I get for developing Puppet code 
in a vacuum. :-)


class someclass (
     $parm1 = $::someclass::params::parm1,
     $parm2 = $::someclass::params::parm2       # so far I get it.
) inherits someclass::params {             # ok, I get it

      class{'someclass::package': }        # OK
      -> class('someclass::configure':}    # right...
      -> Class{'someclass':}                    #  HUH?  What does that do?
}

Is that last step necessary and why?



The last step was fairly common in Puppet 2.7 code before Anchors. It is 
necessary if you want to do something like this.


class profile::mystack {

  include ::otherclass
  include ::someclass

  Class['someclass'] -> Class['otherclass']
}

By adding that -> Class{'someclass':} to the end you create a chain that 
requires all classes to completed before 'someclass' is completed. 
Allows you to do the ordering I've shown.


In Puppet 3.4 the keyword 'contain' was introduced. The modern 
implementation might look like


class someclass (
$parm1 = $::someclass::params::parm1,
$parm2 = $::someclass::params::parm2,
) inherits someclass::params {

  contain someclass::package
  contain someclass::configure

  Class['someclass::package']
  -> Class['someclass::configure']
}

fwiw a lot of my modules internally will mix and match include with 
contain. In the case below I do not want containment around the yum repo 
because in our system that's guaranteed to cause dependency cycles. Also 
service usually encapsulate some systemd reloading which can cause the 
same problem. Containing install and config is usually enough to allow 
other modules to depend on my somedaemon module though not always.


class somedaemon {

  include ::somedaemon::repo
  contain ::somedaemon::install
  contain ::somedaemon::config
  include ::somedaemon::service

  Class['::yum']
  -> class['::somedaemon::install']
  -> Class['::somedaemon::config']
  ~> Class['::somedaemon::service']
}

Ramin

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/e5e15946-72ca-2cc8-e7e3-e40489d98019%40badapple.net.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Style (syntax?) question

2018-06-04 Thread Peter Berghold
I was looking at someone else's code one day last week and saw a pattern
I've not seen before. Maybe that's what I get for developing Puppet code in
a vacuum. :-)

class someclass (
$parm1 = $::someclass::params::parm1,
$parm2 = $::someclass::params::parm2   # so far I get it.
) inherits someclass::params { # ok, I get it

 class{'someclass::package': }# OK
 -> class('someclass::configure':}# right...
 -> Class{'someclass':}#  HUH?  What does that do?
}

Is that last step necessary and why?

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAArvnv22e-Wbp8dtD9bUHTOxf68e8p3rWdNP8A2pFR6txAamzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.