-
-
Notifications
You must be signed in to change notification settings - Fork 881
/
init.pp
316 lines (302 loc) · 12 KB
/
init.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# Class: nginx
#
# This module manages NGINX.
#
# Parameters:
#
# Actions:
#
# Requires:
# puppetlabs-stdlib - https://github.com/puppetlabs/puppetlabs-stdlib
#
# Packaged NGINX
# - RHEL: EPEL or custom package
# - Debian/Ubuntu: Default Install or custom package
# - SuSE: Default Install or custom package
#
# stdlib
# - puppetlabs-stdlib module >= 0.1.6
# - plugin sync enabled to obtain the anchor type
#
# Sample Usage:
#
# The module works with sensible defaults:
#
# node default {
# include nginx
# }
class nginx (
### START Nginx Configuration ###
$client_body_buffer_size = undef,
$client_body_temp_path = undef,
$client_max_body_size = undef,
$events_use = undef,
$fastcgi_cache_inactive = undef,
$fastcgi_cache_key = undef,
$fastcgi_cache_keys_zone = undef,
$fastcgi_cache_levels = undef,
$fastcgi_cache_max_size = undef,
$fastcgi_cache_path = undef,
$fastcgi_cache_use_stale = undef,
$gzip = undef,
$http_cfg_append = undef,
$http_tcp_nodelay = undef,
$http_tcp_nopush = undef,
$keepalive_timeout = undef,
$mail = undef,
$multi_accept = undef,
$names_hash_bucket_size = undef,
$names_hash_max_size = undef,
$proxy_buffers = undef,
$proxy_buffer_size = undef,
$proxy_cache_inactive = undef,
$proxy_cache_keys_zone = undef,
$proxy_cache_levels = undef,
$proxy_cache_max_size = undef,
$proxy_cache_path = undef,
$proxy_connect_timeout = undef,
$proxy_headers_hash_bucket_size = undef,
$proxy_http_version = undef,
$proxy_read_timeout = undef,
$proxy_redirect = undef,
$proxy_send_timeout = undef,
$proxy_set_header = undef,
$sendfile = undef,
$server_tokens = undef,
$spdy = undef,
$types_hash_bucket_size = undef,
$types_hash_max_size = undef,
$worker_connections = undef,
$worker_processes = undef,
$worker_rlimit_nofile = undef,
### END Nginx Configuration
### START Module/App Configuration ###
$confd_purge = undef,
$conf_dir = undef,
$daemon_user = undef,
$global_owner = undef,
$global_group = undef,
$global_mode = undef,
$logdir = undef,
$log_format = undef,
$http_access_log = undef,
$nginx_error_log = undef,
$pid = undef,
$proxy_temp_path = undef,
$root_group = undef,
$run_dir = undef,
$sites_available_owner = undef,
$sites_available_group = undef,
$sites_available_mode = undef,
$super_user = undef,
$temp_dir = undef,
$vhost_purge = undef,
# Primary Templates
$conf_template = undef,
$proxy_conf_template = undef,
### END Module/App Configuration ###
### START Package Configuration ###
$package_ensure = present,
$package_name = $::nginx::params::package_name,
$package_source = 'nginx',
$package_flavor = undef,
$manage_repo = $::nginx::params::manage_repo,
### END Package Configuration ###
### START Service Configuation ###
$configtest_enable = false,
$service_ensure = running,
$service_flags = undef,
$service_restart = '/etc/init.d/nginx reload',
$service_name = undef,
### END Service Configuration ###
### START Hiera Lookups ###
$geo_mappings = {},
$string_mappings = {},
$nginx_locations = {},
$nginx_mailhosts = {},
$nginx_upstreams = {},
$nginx_vhosts = {},
$nginx_vhosts_defaults = {},
### END Hiera Lookups ###
) inherits ::nginx::params {
### DEPRECATION WARNING ###
###
### During the transition from the params pattern -> puppet-module-data,
### we need a graceful way to notify the consumer that the pattern is
### changing, and point them toward docs on how to transition.
###
### Once we hit 1.0, this whole block goes away.
###
### Please note: as a contributor to this module, no Pulls will be accepted
### that do add additional parameters to this class. Get on this puppet-module-data
### level!
### This block makes me sad, but what can you do.... we need to do this
### migration the Right Way(tm) -- JDF
if $client_body_buffer_size or
$client_body_temp_path or
$client_max_body_size or
$confd_purge or
$conf_dir or
$conf_template or
$daemon_user or
$events_use or
$fastcgi_cache_inactive or
$fastcgi_cache_key or
$fastcgi_cache_keys_zone or
$fastcgi_cache_levels or
$fastcgi_cache_max_size or
$fastcgi_cache_path or
$fastcgi_cache_use_stale or
$gzip or
$http_access_log or
$http_cfg_append or
$http_tcp_nodelay or
$http_tcp_nopush or
$keepalive_timeout or
$logdir or
$log_format or
$mail or
$multi_accept or
$names_hash_bucket_size or
$names_hash_max_size or
$nginx_error_log or
$pid or
$proxy_buffers or
$proxy_buffer_size or
$proxy_cache_inactive or
$proxy_cache_keys_zone or
$proxy_cache_levels or
$proxy_cache_max_size or
$proxy_cache_path or
$proxy_conf_template or
$proxy_connect_timeout or
$proxy_headers_hash_bucket_size or
$proxy_http_version or
$proxy_read_timeout or
$proxy_redirect or
$proxy_send_timeout or
$proxy_set_header or
$proxy_temp_path or
$run_dir or
$sendfile or
$server_tokens or
$spdy or
$super_user or
$temp_dir or
$types_hash_bucket_size or
$types_hash_max_size or
$vhost_purge or
$worker_connections or
$worker_processes or
$worker_rlimit_nofile or
$global_owner or
$global_group or
$global_mode or
$sites_available_owner or
$sites_available_group or
$sites_available_mode {
include ::nginx::notice::config
}
### END DEPRECATION WARNING ###
class { '::nginx::package':
package_name => $package_name,
package_source => $package_source,
package_ensure => $package_ensure,
package_flavor => $package_flavor,
notify => Class['::nginx::service'],
manage_repo => $manage_repo,
}
## This `if` statement is here in the event a user cannot use
## Hiera based parameter overrides. Will not be here in 1.0 release
if !defined(Class['::nginx::config']) {
class { '::nginx::config':
client_body_buffer_size => $client_body_buffer_size,
client_body_temp_path => $client_body_temp_path,
client_max_body_size => $client_max_body_size,
confd_purge => $confd_purge,
conf_dir => $conf_dir,
conf_template => $conf_template,
daemon_user => $daemon_user,
events_use => $events_use,
fastcgi_cache_inactive => $fastcgi_cache_inactive,
fastcgi_cache_key => $fastcgi_cache_key,
fastcgi_cache_keys_zone => $fastcgi_cache_keys_zone,
fastcgi_cache_levels => $fastcgi_cache_levels,
fastcgi_cache_max_size => $fastcgi_cache_max_size,
fastcgi_cache_path => $fastcgi_cache_path,
fastcgi_cache_use_stale => $fastcgi_cache_use_stale,
gzip => $gzip,
http_access_log => $http_access_log,
http_cfg_append => $http_cfg_append,
http_tcp_nodelay => $http_tcp_nodelay,
http_tcp_nopush => $http_tcp_nopush,
keepalive_timeout => $keepalive_timeout,
log_dir => $logdir,
log_format => $log_format,
mail => $mail,
multi_accept => $multi_accept,
names_hash_bucket_size => $names_hash_bucket_size,
names_hash_max_size => $names_hash_max_size,
nginx_error_log => $nginx_error_log,
pid => $pid,
proxy_buffers => $proxy_buffers,
proxy_buffer_size => $proxy_buffer_size,
proxy_cache_inactive => $proxy_cache_inactive,
proxy_cache_keys_zone => $proxy_cache_keys_zone,
proxy_cache_levels => $proxy_cache_levels,
proxy_cache_max_size => $proxy_cache_max_size,
proxy_cache_path => $proxy_cache_path,
proxy_conf_template => $proxy_conf_template,
proxy_connect_timeout => $proxy_connect_timeout,
proxy_headers_hash_bucket_size => $proxy_headers_hash_bucket_size,
proxy_http_version => $proxy_http_version,
proxy_read_timeout => $proxy_read_timeout,
proxy_redirect => $proxy_redirect,
proxy_send_timeout => $proxy_send_timeout,
proxy_set_header => $proxy_set_header,
proxy_temp_path => $proxy_temp_path,
run_dir => $run_dir,
sendfile => $sendfile,
server_tokens => $server_tokens,
spdy => $spdy,
super_user => $super_user,
temp_dir => $temp_dir,
types_hash_bucket_size => $types_hash_bucket_size,
types_hash_max_size => $types_hash_max_size,
vhost_purge => $vhost_purge,
worker_connections => $worker_connections,
worker_processes => $worker_processes,
worker_rlimit_nofile => $worker_rlimit_nofile,
global_owner => $global_owner,
global_group => $global_group,
global_mode => $global_mode,
sites_available_owner => $sites_available_owner,
sites_available_group => $sites_available_group,
sites_available_mode => $sites_available_mode,
}
}
Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service']
class { '::nginx::service':
configtest_enable => $configtest_enable,
service_ensure => $service_ensure,
service_restart => $service_restart,
service_name => $service_name,
service_flags => $service_flags,
}
create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
create_resources('nginx::resource::location', $nginx_locations)
create_resources('nginx::resource::mailhost', $nginx_mailhosts)
create_resources('nginx::resource::map', $string_mappings)
create_resources('nginx::resource::geo', $geo_mappings)
# Allow the end user to establish relationships to the "main" class
# and preserve the relationship to the implementation classes through
# a transitive relationship to the composite class.
anchor{ 'nginx::begin':
before => Class['::nginx::package'],
notify => Class['::nginx::service'],
}
anchor { 'nginx::end':
require => Class['::nginx::service'],
}
}