Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having trouble getting parameterised classes working in puppet 2.6.4 (client and master)

######## from /etc/puppet/manifests/nodes.pp 
# defining one node to use certain version
#######################################################
node 'dev-internal-000008.domain.com' {
         include software($version="dev-2011.02.11")
}
# from /etc/puppet/modules/software/manifests/init.pp

I am setting the version here as the "default"

#
class software($version="dev-2011.02.04b") {
  File {
    links => follow
  }

  file { "/opt/software_AIR":
    ensure => directory
  }

  file { "/opt/software_AIR/share":
    source => "puppet://puppet/software/air/$version",
    recurse => "true",
  }
}
#

errors from puppet master

#
err: Could not parse for environment production: Syntax error at '='; expected ')' at /etc/puppet/manifests/nodes.pp:10 on node dev-internal-domain.com
#

found a fix for this

try

node 'dev-internal-000008.domain.com' {
  class { customsoftware:version => "dev-2011.02.04b" }
}
share|improve this question
    
My syntax was wrong in the nodes.pp.. node 'dev-internal-000008.domain.com' { class { customsoftware:version => "dev-2011.02.04b" } } –  Joey BagODonuts Feb 25 '11 at 20:40

1 Answer 1

up vote 6 down vote accepted

Parameterized classes don't work with include, unfortunately. You have to use the new alternate class declaration syntax that was introduced at the same time as parameterized classes:

node 'dev-internal-000008.domain.com' {
    # include software($version="dev-2011.02.11") # (doesn't work)
    class {'software':
        version => "dev-2011.02.11",
    } # works
}

Things:

  • Note that it looks like a resource (file, service, etc.) declaration.
  • The fact that the definition and the declaration both start with the word class is confusing, but be careful and you'll be fine.
  • You can't declare a class this way more than once, the way you can with include. This is expected to change in 2.7, and some friendlier syntax will likely be introduced.
share|improve this answer

Your Answer

 
discard

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.