|
1 # Class: apache::service |
|
2 # |
|
3 # Manages the Apache daemon |
|
4 # |
|
5 # Parameters: |
|
6 # |
|
7 # Actions: |
|
8 # - Manage Apache service |
|
9 # |
|
10 # Requires: |
|
11 # |
|
12 # Sample Usage: |
|
13 # |
|
14 # sometype { 'foo': |
|
15 # notify => Class['apache::service'], |
|
16 # } |
|
17 # |
|
18 # |
|
19 class apache::service ( |
|
20 $service_name = $::apache::params::service_name, |
|
21 $service_enable = true, |
|
22 $service_ensure = 'running', |
|
23 $service_manage = true, |
|
24 $service_restart = undef |
|
25 ) { |
|
26 # The base class must be included first because parameter defaults depend on it |
|
27 if ! defined(Class['apache::params']) { |
|
28 fail('You must include the apache::params class before using any apache defined resources') |
|
29 } |
|
30 validate_bool($service_enable) |
|
31 validate_bool($service_manage) |
|
32 |
|
33 case $service_ensure { |
|
34 true, false, 'running', 'stopped': { |
|
35 $_service_ensure = $service_ensure |
|
36 } |
|
37 default: { |
|
38 $_service_ensure = undef |
|
39 } |
|
40 } |
|
41 if $service_manage { |
|
42 service { 'httpd': |
|
43 ensure => $_service_ensure, |
|
44 name => $service_name, |
|
45 enable => $service_enable, |
|
46 restart => $service_restart |
|
47 } |
|
48 } |
|
49 } |