|
1 define apache::mod ( |
|
2 $package = undef, |
|
3 $package_ensure = 'present', |
|
4 $lib = undef, |
|
5 $lib_path = $::apache::lib_path, |
|
6 $id = undef, |
|
7 $path = undef, |
|
8 $loadfile_name = undef, |
|
9 $loadfiles = undef, |
|
10 ) { |
|
11 if ! defined(Class['apache']) { |
|
12 fail('You must include the apache base class before using any apache defined resources') |
|
13 } |
|
14 |
|
15 $mod = $name |
|
16 #include apache #This creates duplicate resources in rspec-puppet |
|
17 $mod_dir = $::apache::mod_dir |
|
18 |
|
19 # Determine if we have special lib |
|
20 $mod_libs = $::apache::params::mod_libs |
|
21 if $lib { |
|
22 $_lib = $lib |
|
23 } elsif has_key($mod_libs, $mod) { # 2.6 compatibility hack |
|
24 $_lib = $mod_libs[$mod] |
|
25 } else { |
|
26 $_lib = "mod_${mod}.so" |
|
27 } |
|
28 |
|
29 # Determine if declaration specified a path to the module |
|
30 if $path { |
|
31 $_path = $path |
|
32 } else { |
|
33 $_path = "${lib_path}/${_lib}" |
|
34 } |
|
35 |
|
36 if $id { |
|
37 $_id = $id |
|
38 } else { |
|
39 $_id = "${mod}_module" |
|
40 } |
|
41 |
|
42 if $loadfile_name { |
|
43 $_loadfile_name = $loadfile_name |
|
44 } else { |
|
45 $_loadfile_name = "${mod}.load" |
|
46 } |
|
47 |
|
48 # Determine if we have a package |
|
49 $mod_packages = $::apache::params::mod_packages |
|
50 if $package { |
|
51 $_package = $package |
|
52 } elsif has_key($mod_packages, $mod) { # 2.6 compatibility hack |
|
53 $_package = $mod_packages[$mod] |
|
54 } else { |
|
55 $_package = undef |
|
56 } |
|
57 if $_package and ! defined(Package[$_package]) { |
|
58 # note: FreeBSD/ports uses apxs tool to activate modules; apxs clutters |
|
59 # httpd.conf with 'LoadModule' directives; here, by proper resource |
|
60 # ordering, we ensure that our version of httpd.conf is reverted after |
|
61 # the module gets installed. |
|
62 $package_before = $::osfamily ? { |
|
63 'freebsd' => [ |
|
64 File[$_loadfile_name], |
|
65 File["${::apache::conf_dir}/${::apache::params::conf_file}"] |
|
66 ], |
|
67 default => File[$_loadfile_name], |
|
68 } |
|
69 # if there are any packages, they should be installed before the associated conf file |
|
70 Package[$_package] -> File<| title == "${mod}.conf" |> |
|
71 # $_package may be an array |
|
72 package { $_package: |
|
73 ensure => $package_ensure, |
|
74 require => Package['httpd'], |
|
75 before => $package_before, |
|
76 } |
|
77 } |
|
78 |
|
79 file { $_loadfile_name: |
|
80 ensure => file, |
|
81 path => "${mod_dir}/${_loadfile_name}", |
|
82 owner => 'root', |
|
83 group => $::apache::params::root_group, |
|
84 mode => '0644', |
|
85 content => template('apache/mod/load.erb'), |
|
86 require => [ |
|
87 Package['httpd'], |
|
88 Exec["mkdir ${mod_dir}"], |
|
89 ], |
|
90 before => File[$mod_dir], |
|
91 notify => Class['apache::service'], |
|
92 } |
|
93 |
|
94 if $::osfamily == 'Debian' { |
|
95 $enable_dir = $::apache::mod_enable_dir |
|
96 file{ "${_loadfile_name} symlink": |
|
97 ensure => link, |
|
98 path => "${enable_dir}/${_loadfile_name}", |
|
99 target => "${mod_dir}/${_loadfile_name}", |
|
100 owner => 'root', |
|
101 group => $::apache::params::root_group, |
|
102 mode => '0644', |
|
103 require => [ |
|
104 File[$_loadfile_name], |
|
105 Exec["mkdir ${enable_dir}"], |
|
106 ], |
|
107 before => File[$enable_dir], |
|
108 notify => Class['apache::service'], |
|
109 } |
|
110 # Each module may have a .conf file as well, which should be |
|
111 # defined in the class apache::mod::module |
|
112 # Some modules do not require this file. |
|
113 if defined(File["${mod}.conf"]) { |
|
114 file{ "${mod}.conf symlink": |
|
115 ensure => link, |
|
116 path => "${enable_dir}/${mod}.conf", |
|
117 target => "${mod_dir}/${mod}.conf", |
|
118 owner => 'root', |
|
119 group => $::apache::params::root_group, |
|
120 mode => '0644', |
|
121 require => [ |
|
122 File["${mod}.conf"], |
|
123 Exec["mkdir ${enable_dir}"], |
|
124 ], |
|
125 before => File[$enable_dir], |
|
126 notify => Class['apache::service'], |
|
127 } |
|
128 } |
|
129 } elsif $::osfamily == 'Suse' { |
|
130 $enable_dir = $::apache::mod_enable_dir |
|
131 file{ "${_loadfile_name} symlink": |
|
132 ensure => link, |
|
133 path => "${enable_dir}/${_loadfile_name}", |
|
134 target => "${mod_dir}/${_loadfile_name}", |
|
135 owner => 'root', |
|
136 group => $::apache::params::root_group, |
|
137 mode => '0644', |
|
138 require => [ |
|
139 File[$_loadfile_name], |
|
140 Exec["mkdir ${enable_dir}"], |
|
141 ], |
|
142 before => File[$enable_dir], |
|
143 notify => Class['apache::service'], |
|
144 } |
|
145 # Each module may have a .conf file as well, which should be |
|
146 # defined in the class apache::mod::module |
|
147 # Some modules do not require this file. |
|
148 if defined(File["${mod}.conf"]) { |
|
149 file{ "${mod}.conf symlink": |
|
150 ensure => link, |
|
151 path => "${enable_dir}/${mod}.conf", |
|
152 target => "${mod_dir}/${mod}.conf", |
|
153 owner => 'root', |
|
154 group => $::apache::params::root_group, |
|
155 mode => '0644', |
|
156 require => [ |
|
157 File["${mod}.conf"], |
|
158 Exec["mkdir ${enable_dir}"], |
|
159 ], |
|
160 before => File[$enable_dir], |
|
161 notify => Class['apache::service'], |
|
162 } |
|
163 } |
|
164 } |
|
165 |
|
166 Apache::Mod[$name] -> Anchor['::apache::modules_set_up'] |
|
167 } |