Advertisement
fatmcgav

notify define

Nov 23rd, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.14 KB | None | 0 0
  1. -- Code
  2. define foo(){
  3.  
  4.    exec { "${name}_exec":
  5.      command     => "echo hello ${name}",
  6.      path        => '/bin:/usr/bin',
  7.      refreshonly => true,
  8.      logoutput   => true,
  9.    }
  10.  
  11.    anchor { 'foo_begin':
  12.         subscribe => Exec["${name}_exec"]
  13.         }
  14.  
  15.    file { "${name}_file":
  16.      path => "/tmp/${name}",
  17.      content => "Test file for ${name}\n",
  18.      ensure => file,
  19.      subscribe => Exec["${name}_exec"]
  20.      }
  21.     ->
  22.     notify {'Notify_works':}
  23.  
  24.    anchor { 'foo_end':
  25.         notify => Notify['foo_done']
  26.         }
  27.  
  28.    notify { 'foo_done':
  29.         message => "Foo is done"
  30.         }
  31.  
  32. }
  33.  
  34. ...
  35. class act::server::linux::db::oracle inherits act::server::linux {
  36.  
  37.   # Check if oracle is installed. If not, install it.
  38.   if !$::oracle_installed {
  39.  
  40.     notify {'oracle_not_installed':
  41.       message => "Oracle is not installed. Installing..."}
  42.     # Check if Oracle Version required is defined. Fail if not.
  43.     if $::oracle_version == undef {
  44.       fail("oracle_version is not defined.")
  45.     } else {
  46.       # Include the act::env::oracle class to setup and install oracle.
  47.       class {'act::env::oracle':
  48.         version => $::oracle_version,
  49.       }
  50.     }
  51.  
  52.   } else {
  53.     notify {'oracle_installed':
  54.           message => "Oracle $::oracle_version is already installed. Skipping."}
  55.   }
  56.  
  57. foo { 'bar': }
  58.  
  59.   # Test file
  60.   file { 'test_ora_file':
  61.         ensure => file,
  62.         content => "Test ora file\n",
  63.         path => '/tmp/ora_file',
  64.         notify => Foo['bar']
  65.  
  66.         }
  67.  
  68. }
  69.  
  70. -- Log
  71. Oracle 11.2.0.3 is already installed. Skipping.
  72. /Stage[main]/Act::Server::Linux::Db::Oracle/Notify[oracle_installed]/message: defined 'message' as 'Oracle 11.2.0.3 is already installed. Skipping.'
  73. Foo is done
  74. /Stage[main]/Act::Server::Linux::Db::Oracle/Foo[bar]/Notify[foo_done]/message: defined 'message' as 'Foo is done'
  75. Notify_works
  76. /Stage[main]/Act::Server::Linux::Db::Oracle/Foo[bar]/Notify[Notify_works]/message: defined 'message' as 'Notify_works'
  77. Environment = production
  78. /Stage[main]//Notify[environment]/message: defined 'message' as 'Environment = production'
  79. Finished catalog run in 1.52 seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement