Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Puppet must hate me. I have been reading the doc for hours on end and still cannot manage to achieve the following:

  • a class or module (or what is it called) with a variable in it (a parameterized class?);
  • this class to be included multiple times in a single host.

In pseudo-code, that would be:

# The class
classorwhatever myclass ($value) {
    notify { "$value world" }

# In the node definition
node whatever {

I feel so stupid it is not even funny. I know it must be doable. But how? :(

share|improve this question
You are reading this? What vrsion of puppet is on your server/client? – Zoredache Jan 18 '12 at 17:07
@Zoredache 2.6.12 on both the server and clients – fge Jan 18 '12 at 22:13
up vote 10 down vote accepted

You can only use a parameterized class once. If you plan to hit a node several times with a function while varying the data definitions are the way to go.


class apache ( $module ) {
  if module = ssl then and so on

define apache::vhost ($priority=99) {
  file { "apache/vhost.d/${name}":
    content => template("apache/vhosts/$name.erb"),

node webserver {
  class { 'apache': module => 'ssl', }
  apache::vhost { 'www': priority => 00, }
  apache::vhost { 'test': priority => 99, } 
share|improve this answer
Thanks, I was able to achieve what I wanted at last! – fge Jan 19 '12 at 8:21
Excellent. fwiw #puppet on freenode and the mail lists are very active and have covered things like this in depth. If you're just getting started with Puppet I'd suggest keep both those resources on hand. – kashani Jan 19 '12 at 21:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.