Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.97 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #First class = role web (calls logstash::common to setup directory structure)
  2. class logstash::web(
  3.    $version = '1.1.0beta8'
  4. ) {
  5.    if !defined(Class['logstash::common']) {
  6.       class {'logstash::common':
  7.          version => $version
  8.       }
  9.    }
  10. }
  11.  
  12. #Second class = role shipper (calls logstash::common to setup directory structure)
  13. class logstash::shipper(
  14.    $version = '1.1.0beta8'
  15. ) {
  16.    if !defined(Class['logstash::common']) {
  17.       class {'logstash::common':
  18.          version => $version
  19.       }
  20.    }
  21. }
  22.  
  23. # Now on the same node:
  24. class {'logtash::web':}
  25. class {'logtash::shipper':}
  26.  
  27. #---> this will tell me I'm redefining class 'logstash::common'. Fair enough
  28. # The solution I found is to use include logstash::common
  29. # But that doesn't allow me to use params? just include
  30. # Is there something like virtualized classes ?
  31. # Or maybe I need to move my classes to defines?
  32.  
  33. # A possible solution is to use `if !defined`.  You'll need to add a dependency
  34. # if you want one to have precedence.