-
-
Save cwarden/1705587 to your computer and use it in GitHub Desktop.
Puppet puzzle : parametrized classes - common logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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