Guest

Monachus

By: a guest on Feb 8th, 2010  |  syntax: None  |  size: 0.81 KB  |  hits: 96  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. *** OLD WAY ***
  2.  
  3. node basenode {
  4.   include global::test
  5. }
  6.  
  7. node node1 inherits basenode {
  8.   $mta = "postfix"
  9.  
  10.   include global::test2
  11. }
  12.  
  13. class global::test {
  14.   notice("$mta: ${mta}")  ## $mta is unset
  15. }
  16.  
  17. class global::test2 {
  18.   notice("$mta: ${mta}")  ## $mta == 'postfix'
  19. }
  20.  
  21.  
  22. *** NEW WAY ***
  23.  
  24. node basenode {
  25.   # ONLY USED TO SET DEFAULT VARIABLES
  26.   $mta = "exim4"
  27.  
  28. }
  29.  
  30. node node1 inherits basenode {
  31.   $mta = "postfix"
  32.  
  33.   include global::base  
  34.   include global::test2
  35. }
  36.  
  37. class global::base {
  38.   # USED TO INCLUDE CLASSES _AFTER_ VARIABLES/TAGS HAVE BEEN SET FOR NODES
  39.   include global::test
  40. }
  41.  
  42. class global::test {
  43.   notice("$mta: ${mta}")  ## $mta == 'postfix' for node1, and 'exim4' for anything else
  44. }
  45.  
  46. class global::test2 {
  47.   notice("$mta: ${mta}")  ## $mta == 'postfix'
  48. }