Skip to content

Instantly share code, notes, and snippets.

@cwarden
Forked from jedi4ever/gist:1704761
Created January 30, 2012 17:37
Show Gist options
  • Save cwarden/1705587 to your computer and use it in GitHub Desktop.
Save cwarden/1705587 to your computer and use it in GitHub Desktop.
Puppet puzzle : parametrized classes - common logic
#First class = role web (calls logstash::common to setup directory structure)
class logstash::web(
$version = '1.1.0beta8'
) {
if !defined(Class['logstash::common']) {
class {'logstash::common':
version => $version
}
}
}
#Second class = role shipper (calls logstash::common to setup directory structure)
class logstash::shipper(
$version = '1.1.0beta8'
) {
if !defined(Class['logstash::common']) {
class {'logstash::common':
version => $version
}
}
}
# Now on the same node:
class {'logtash::web':}
class {'logtash::shipper':}
#---> this will tell me I'm redefining class 'logstash::common'. Fair enough
# The solution I found is to use include logstash::common
# But that doesn't allow me to use params? just include
# Is there something like virtualized classes ?
# Or maybe I need to move my classes to defines?
# A possible solution is to use `if !defined`. You'll need to add a dependency
# if you want one to have precedence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment