Puppet parameterized class - include for declaration?

229 views
Skip to first unread message

Shantanu

unread,
Apr 8, 2013, 5:10:03 PM4/8/13
to puppet...@googlegroups.com

The parameterized classes guide mentions that a parameterized class is declared using following syntax [1]:

    class {'classname': }


But the puppetlabs postgresql module mentions that a parameterized class 'postgresql::server' can be declared using 'include' syntax [2]. 

So is 'include' syntax supported for parameterized classes now?

--
Shantanu




joe

unread,
Apr 9, 2013, 3:18:18 AM4/9/13
to puppet...@googlegroups.com
You can include a parameterized class as long as all it's parameters have default values.

jcbollinger

unread,
Apr 9, 2013, 9:00:40 AM4/9/13
to puppet...@googlegroups.com


On Monday, April 8, 2013 4:10:03 PM UTC-5, Shantanu wrote:

The parameterized classes guide mentions that a parameterized class is declared using following syntax [1]:

    class {'classname': }


But the puppetlabs postgresql module mentions that a parameterized class 'postgresql::server' can be declared using 'include' syntax [2]. 

So is 'include' syntax supported for parameterized classes now?


The 'include' function has always worked with parameterized classes.  It just doesn't bind any parameter values to the named class.  Indeed, the parameterized-style class declaration syntax is better viewed as a parameter binding syntax, with a side effect of declaring the class.  That makes it a lot easier to understand its constraints -- principally, that if a parameterized-style class declaration is used, for a given class then it must be the first declaration of that class that is evaluated. (Any number of 'include' declarations may be used for the same class.)

Using the 'include' function with parameterized classes makes especial sense when relying exclusively on Puppet 3's automated hiera-based data binding, because there is nothing but downside to using empty parameterized-style class declarations.

Note, too, that you can use (empty) parameterized declarations for UNparameterized classes.  But don't do that.


John


Peter Brown

unread,
Apr 9, 2013, 7:40:33 PM4/9/13
to puppet-users
On 9 April 2013 17:18, joe <lav...@gmail.com> wrote:
You can include a parameterized class as long as all it's parameters have default values.

or you use hiera or an External Node Classifier to automagically set the variables that don't have defaults or override that ones you need to.
 


On Monday, April 8, 2013 3:10:03 PM UTC-6, Shantanu wrote:

The parameterized classes guide mentions that a parameterized class is declared using following syntax [1]:

    class {'classname': }


But the puppetlabs postgresql module mentions that a parameterized class 'postgresql::server' can be declared using 'include' syntax [2]. 

So is 'include' syntax supported for parameterized classes now?

--
Shantanu




--
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...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Shantanu

unread,
Apr 10, 2013, 6:00:37 PM4/10/13
to puppet...@googlegroups.com
Thanks for explaining it John. I have always used empty parameterized declaration syntax. I had wrongly assumed that include won't work with it. 

--
Shantanu



Reply all
Reply to author
Forward
0 new messages