28
|
1 |
# = Define puppi::project::maven |
|
2 |
# |
|
3 |
# This is a shortcut define to build a puppi project for the |
|
4 |
# deploy of war and tar files generated via Maven and published on |
|
5 |
# a repository like Sonar. |
|
6 |
# |
|
7 |
# It uses different "core" defines (puppi::project, puppi:deploy (many), |
|
8 |
# puppi::rollback (many)) to build a full featured template project for |
|
9 |
# automatic deployments. |
|
10 |
# If you need to customize it, either change the template defined here or |
|
11 |
# build up your own custom ones. |
|
12 |
# |
|
13 |
# == Variables: |
|
14 |
# |
|
15 |
# [*source*] |
|
16 |
# The full URL of the maven-metadata.xml file to retrieve. |
|
17 |
# Format should be in URI standard (http:// file:// ssh:// rsync://). |
|
18 |
# |
|
19 |
# [*http_password*] |
|
20 |
# The http_password to use for authentication to the source in case of http. |
|
21 |
# |
|
22 |
# [*http_user*] |
|
23 |
# The http_user to use for authentication to the source in case of http. |
|
24 |
# |
|
25 |
# [*artifact_type*] |
|
26 |
# The artifact_type to parse the maven-metadata.xml. Either "release", "latest" or |
|
27 |
# a specific version (e.g. "2.5.0") |
|
28 |
# Default is "release". With artifactory, don't use the |
|
29 |
# "Maven Snapshot Version Behavior" "unique" for your repository. |
|
30 |
# |
|
31 |
# [*deploy_root*] |
|
32 |
# The destination directory where file(s) are deployed. |
|
33 |
# |
|
34 |
# [*user*] |
|
35 |
# (Optional) - The user to be used for deploy operations. |
|
36 |
# |
|
37 |
# [*war_suffix*] |
|
38 |
# (Optional) - The suffix (Maven qualifier) that might be appended to the war |
|
39 |
# |
|
40 |
# [*zip_root*] |
|
41 |
# (Optional) - The destination directory where the zip is unpacked |
|
42 |
# |
|
43 |
# [*zip_user*] |
|
44 |
# (Optional) - The user to be used for deploy operations of the zip |
|
45 |
# |
|
46 |
# [*zip_suffix*] |
|
47 |
# (Optional) - The suffix (Maven qualifier) that might be appended to the zip |
|
48 |
# |
|
49 |
# [*jar_root*] |
|
50 |
# (Optional) - The destination directory where the jar is copied. |
|
51 |
# If set a jar file is searched in Maven |
|
52 |
# |
|
53 |
# [*jar_user*] |
|
54 |
# (Optional) - The user to be used for deploy operations of the jar |
|
55 |
# (owner of the files deployed in $jar_root) |
|
56 |
# |
|
57 |
# [*jar_suffix*] |
|
58 |
# (Optional) - The suffix (Maven qualifier) that might be appended to the jar |
|
59 |
# |
|
60 |
# [*document_root*] |
|
61 |
# (Optional) - The destination directory where the eventual tarball generated |
|
62 |
# via Maven containing static files ("src tar") is unpacked |
|
63 |
# |
|
64 |
# [*document_suffix*] |
|
65 |
# (Optional) - The suffix (Maven qualifier) that might be appended to the |
|
66 |
# static files tarballs ("src tar") |
|
67 |
# |
|
68 |
# [*document_init_source*] |
|
69 |
# (Optional) - The full URL to be used to retrieve, for the first time, the |
|
70 |
# project files present in the source tarball. They are copied to the |
|
71 |
# $document_root. Format should be in URI standard (http:// file:// ...) |
|
72 |
# |
|
73 |
# [*document_user*] |
|
74 |
# (Optional) - The user to be used for deploy operations of the tarball |
|
75 |
# (owner of the files in $document_root) |
|
76 |
# |
|
77 |
# [*config_root*] |
|
78 |
# (Optional) - The destination directory where the cfg tar is unpacked |
|
79 |
# |
|
80 |
# [*config_suffix*] |
|
81 |
# (Optional) - The suffix (Maven qualifier) that might be appended to |
|
82 |
# configuration tarballs ("cfg tar") |
|
83 |
# |
|
84 |
# [*config_init_source*] |
|
85 |
# (Optional) - The full URL to be used to retrieve, for the first time, the |
|
86 |
# project files present in the cfg tar. They are copied to the $config_root. |
|
87 |
# Format should be in URI standard (http:// file:// ssh:// svn://) |
|
88 |
# |
|
89 |
# [*config_user*] |
|
90 |
# (Optional) - The user to be used for deploy operations of cfg tar |
|
91 |
# (owner of the files in $config_root) |
|
92 |
# |
|
93 |
# [*predeploy_customcommand*] |
|
94 |
# (Optional) - Full path with arguments of an eventual custom command to |
|
95 |
# execute before the deploy. The command is executed as $predeploy_user. |
|
96 |
# |
|
97 |
# [*predeploy_user*] |
|
98 |
# (Optional) - The user to be used to execute the $predeploy_customcommand. |
|
99 |
# By default is the same of $user. |
|
100 |
# |
|
101 |
# [*predeploy_priority*] |
|
102 |
# (Optional) - The priority (execution sequence number) that defines when, |
|
103 |
# during the deploy procedure, the $predeploy_customcommand is executed |
|
104 |
# Default: 39 (immediately before the copy of files on the deploy root). |
|
105 |
# |
|
106 |
# [*postdeploy_customcommand*] |
|
107 |
# (Optional) - Full path with arguments of an eventual custom command to |
|
108 |
# execute after the deploy. The command is executed as $postdeploy_user. |
|
109 |
# |
|
110 |
# [*postdeploy_user*] |
|
111 |
# (Optional) - The user to be used to execute the $postdeploy_customcommand. |
|
112 |
# By default is the same of $user. |
|
113 |
# |
|
114 |
# [*postdeploy_priority*] |
|
115 |
# (Optional) - The priority (execution sequence number) that defines when, |
|
116 |
# during the deploy procedure, the $postdeploy_customcommand is executed |
|
117 |
# Default: 41 (immediately after the copy of files on the deploy root). |
|
118 |
# |
|
119 |
# [*init_script*] |
|
120 |
# (Optional - Obsolete) - The name (ex: tomcat) of the init script of your |
|
121 |
# Application server. If you define it, the AS is stopped and then started |
|
122 |
# during deploy. This option is deprecated, you can use $disable_services |
|
123 |
# for the same functionality |
|
124 |
# |
|
125 |
# [*disable_services*] |
|
126 |
# (Optional) - The names (space separated) of the services you might want to |
|
127 |
# stop during deploy. By default is blank. Example: "apache puppet monit". |
|
128 |
# |
|
129 |
# [*firewall_src_ip*] |
|
130 |
# (Optional) - The IP address of a loadbalancer you might want to block out |
|
131 |
# during a deploy. |
|
132 |
# |
|
133 |
# [*firewall_dst_port*] |
|
134 |
# (Optional) - The local port to block from the loadbalancer during deploy |
|
135 |
# (Default all). |
|
136 |
# |
|
137 |
# [*firewall_delay*] |
|
138 |
# (Optional) - A delay time in seconds to wait after the block of |
|
139 |
# $firewall_src_ip. Should be at least as long as the loadbalancer check |
|
140 |
# interval for the services stopped during deploy (Default: 1). |
|
141 |
# |
|
142 |
# [*report_email*] |
|
143 |
# (Optional) - The (space separated) email(s) to notify of deploy/rollback |
|
144 |
# operations. If none is specified, no email is sent. |
|
145 |
# |
|
146 |
# [*report_mongo*] |
|
147 |
# (Optional) - A mongourl with optional user:password to report to. Append the |
|
148 |
# database with a slash ("mongodb://user:password@mymongo.mydomain.com/theNameOfDb") |
|
149 |
# |
|
150 |
# [*backup_rsync_options*] |
|
151 |
# (Optional) - The extra options to pass to rsync for backup operations. Use |
|
152 |
# it, for example, to exclude directories that you don't want to archive. |
|
153 |
# IE: "--exclude .snapshot --exclude cache --exclude www/cache". |
|
154 |
# |
|
155 |
# [*backup_retention*] |
|
156 |
# (Optional) - Number of backup archives to keep. (Default 5). |
|
157 |
# Lower the default value if your backups are too large and may fill up the |
|
158 |
# filesystem. |
|
159 |
# |
|
160 |
# [*run_checks*] |
|
161 |
# (Optional) - If you want to run local puppi checks before and after the |
|
162 |
# deploy procedure. Default: "true". |
|
163 |
# |
|
164 |
# [*always_deploy*] |
|
165 |
# (Optional) - If you always deploy what has been downloaded. Default="yes", |
|
166 |
# if set to "no" a checksum is made between the files previously downloaded |
|
167 |
# and the new files. If they are the same the deploy is not done. |
|
168 |
# |
|
169 |
# [*check_deploy*] |
|
170 |
# (Optional) - Checks if the war is deployed (Default yes). Set to no if |
|
171 |
# you deploy on Jboss or the deployed dir is different for the war filename |
|
172 |
# |
|
173 |
# [*auto_deploy*] |
|
174 |
# (Optional) - If you want to automatically run this puppi deploy when |
|
175 |
# Puppet runs. Default: 'false' |
|
176 |
# |
|
177 |
define puppi::project::maven ( |
|
178 |
$source, |
|
179 |
$http_user = '', |
|
180 |
$http_password = '', |
|
181 |
$artifact_type = 'release', |
|
182 |
$deploy_root = '', |
|
183 |
$user = 'root', |
|
184 |
$war_suffix = 'suffixnotset', |
|
185 |
$zip_root = '', |
|
186 |
$zip_user = '', |
|
187 |
$zip_suffix = 'suffixnotset', |
|
188 |
$jar_root = '', |
|
189 |
$jar_user = '', |
|
190 |
$jar_suffix = 'suffixnotset', |
|
191 |
$document_root = '', |
|
192 |
$document_user = '', |
|
193 |
$document_suffix = 'suffixnotset', |
|
194 |
$document_init_source = '', |
|
195 |
$config_root = '', |
|
196 |
$config_user = '', |
|
197 |
$config_suffix = 'suffixnotset', |
|
198 |
$config_init_source = '', |
|
199 |
$predeploy_customcommand = '', |
|
200 |
$predeploy_user = '', |
|
201 |
$predeploy_priority = '39', |
|
202 |
$postdeploy_customcommand = '', |
|
203 |
$postdeploy_user = '', |
|
204 |
$postdeploy_priority = '41', |
|
205 |
$init_script = '', |
|
206 |
$disable_services = '', |
|
207 |
$firewall_src_ip = '', |
|
208 |
$firewall_dst_port = '0', |
|
209 |
$firewall_delay = '1', |
|
210 |
$report_email = '', |
|
211 |
$report_mongo = '', |
|
212 |
$backup_rsync_options = '--exclude .snapshot', |
|
213 |
$backup_retention = '5', |
|
214 |
$run_checks = true, |
|
215 |
$always_deploy = true, |
|
216 |
$check_deploy = true, |
|
217 |
$auto_deploy = false, |
|
218 |
$enable = true ) { |
|
219 |
|
|
220 |
require puppi |
|
221 |
require puppi::params |
|
222 |
|
|
223 |
# Set default values |
|
224 |
$predeploy_real_user = $predeploy_user ? { |
|
225 |
'' => $user, |
|
226 |
default => $predeploy_user, |
|
227 |
} |
|
228 |
|
|
229 |
$postdeploy_real_user = $postdeploy_user ? { |
|
230 |
'' => $user, |
|
231 |
default => $postdeploy_user, |
|
232 |
} |
|
233 |
|
|
234 |
$config_real_user = $config_user ? { |
|
235 |
'' => $user, |
|
236 |
default => $config_user, |
|
237 |
} |
|
238 |
|
|
239 |
$document_real_user = $document_user ? { |
|
240 |
'' => $user, |
|
241 |
default => $document_user, |
|
242 |
} |
|
243 |
|
|
244 |
$jar_real_user = $jar_user ? { |
|
245 |
'' => $user, |
|
246 |
default => $jar_user, |
|
247 |
} |
|
248 |
|
|
249 |
$zip_real_user = $zip_user ? { |
|
250 |
'' => $user, |
|
251 |
default => $zip_user, |
|
252 |
} |
|
253 |
|
|
254 |
$real_always_deploy = any2bool($always_deploy) ? { |
|
255 |
false => 'no', |
|
256 |
true => 'yes', |
|
257 |
} |
|
258 |
|
|
259 |
$bool_run_checks = any2bool($run_checks) |
|
260 |
$bool_check_deploy = any2bool($check_deploy) |
|
261 |
$bool_auto_deploy = any2bool($auto_deploy) |
|
262 |
|
|
263 |
|
|
264 |
### CREATE PROJECT |
|
265 |
puppi::project { $name: |
|
266 |
enable => $enable , |
|
267 |
} |
|
268 |
|
|
269 |
|
|
270 |
### INIT SEQUENCE |
|
271 |
if ($document_init_source != '') { |
|
272 |
puppi::initialize { "${name}-Deploy_Files": |
|
273 |
priority => '40' , |
|
274 |
command => 'get_file.sh' , |
|
275 |
arguments => "-s ${document_init_source} -d ${deploy_root}" , |
|
276 |
user => $document_real_user , |
|
277 |
project => $name , |
|
278 |
enable => $enable , |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
if ($config_init_source != '') { |
|
283 |
puppi::initialize { "${name}-Deploy_CFG_Files": |
|
284 |
priority => '40' , |
|
285 |
command => 'get_file.sh' , |
|
286 |
arguments => "-s ${config_init_source} -d ${deploy_root}" , |
|
287 |
user => $config_real_user , |
|
288 |
project => $name , |
|
289 |
enable => $enable , |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
### DEPLOY SEQUENCE |
|
294 |
if ($bool_run_checks == true) { |
|
295 |
puppi::deploy { "${name}-Run_PRE-Checks": |
|
296 |
priority => '10' , |
|
297 |
command => 'check_project.sh' , |
|
298 |
arguments => $name , |
|
299 |
user => 'root' , |
|
300 |
project => $name , |
|
301 |
enable => $enable , |
|
302 |
} |
|
303 |
} |
|
304 |
|
|
305 |
$metadata_arguments = $http_password ? { |
|
306 |
'' => "-s ${source}/maven-metadata.xml -t maven-metadata -a ${real_always_deploy}", |
|
307 |
default => "-s ${source}/maven-metadata.xml -t maven-metadata -a ${real_always_deploy} -u ${http_user} -p ${http_password}" |
|
308 |
} |
|
309 |
|
|
310 |
puppi::deploy { "${name}-Get_Maven_Metadata_File": |
|
311 |
priority => '20' , |
|
312 |
command => 'get_file.sh' , |
|
313 |
arguments => $metadata_arguments, |
|
314 |
user => 'root' , |
|
315 |
project => $name , |
|
316 |
enable => $enable , |
|
317 |
} |
|
318 |
|
|
319 |
puppi::deploy { "${name}-Extract_Maven_Metadata": |
|
320 |
priority => '22' , |
|
321 |
command => 'get_metadata.sh' , |
|
322 |
arguments => "-m ${document_suffix} -mc ${config_suffix} -mj ${jar_suffix} -mw ${war_suffix} -mz ${zip_suffix} -at ${artifact_type}" , |
|
323 |
user => 'root' , |
|
324 |
project => $name , |
|
325 |
enable => $enable , |
|
326 |
} |
|
327 |
|
|
328 |
# Files retrieval |
|
329 |
if ($deploy_root != '') { |
|
330 |
$war_arguments = $http_password ? { |
|
331 |
'' => "${source} warfile", |
|
332 |
default => "-u ${http_user} -p ${http_password} ${source} warfile" |
|
333 |
} |
|
334 |
|
|
335 |
puppi::deploy { "${name}-Get_Maven_Files_WAR": |
|
336 |
priority => '25' , |
|
337 |
command => 'get_maven_files.sh' , |
|
338 |
arguments => $war_arguments, |
|
339 |
user => 'root' , |
|
340 |
project => $name , |
|
341 |
enable => $enable , |
|
342 |
} |
|
343 |
} |
|
344 |
|
|
345 |
if ($jar_root != '') { |
|
346 |
puppi::deploy { "${name}-Get_Maven_Files_JAR": |
|
347 |
priority => '25' , |
|
348 |
command => 'get_maven_files.sh' , |
|
349 |
arguments => "${source} jarfile" , |
|
350 |
user => 'root' , |
|
351 |
project => $name , |
|
352 |
enable => $enable , |
|
353 |
} |
|
354 |
} |
|
355 |
|
|
356 |
if ($config_root != '') { |
|
357 |
puppi::deploy { "${name}-Get_Maven_Files_Config": |
|
358 |
priority => '25' , |
|
359 |
command => 'get_maven_files.sh' , |
|
360 |
arguments => "${source} configfile" , |
|
361 |
user => 'root' , |
|
362 |
project => $name , |
|
363 |
enable => $enable , |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
367 |
if ($document_root != '') { |
|
368 |
puppi::deploy { "${name}-Get_Maven_Files_SRC": |
|
369 |
priority => '25' , |
|
370 |
command => 'get_maven_files.sh' , |
|
371 |
arguments => "${source} srcfile" , |
|
372 |
user => 'root' , |
|
373 |
project => $name , |
|
374 |
enable => $enable , |
|
375 |
} |
|
376 |
} |
|
377 |
|
|
378 |
if ($zip_root != '') { |
|
379 |
$real_arguments = $http_password ? { |
|
380 |
'' => "${source} zipfile", |
|
381 |
default => "-u ${http_user} -p ${http_password} ${source} zipfile" |
|
382 |
} |
|
383 |
|
|
384 |
puppi::deploy { "${name}-Get_Maven_Files_ZIP": |
|
385 |
priority => '25' , |
|
386 |
command => 'get_maven_files.sh' , |
|
387 |
arguments => $real_arguments, |
|
388 |
user => 'root' , |
|
389 |
project => $name , |
|
390 |
enable => $enable , |
|
391 |
} |
|
392 |
} |
|
393 |
|
|
394 |
if ($firewall_src_ip != '') { |
|
395 |
puppi::deploy { "${name}-Load_Balancer_Block": |
|
396 |
priority => '30' , |
|
397 |
command => 'firewall.sh' , |
|
398 |
arguments => "${firewall_src_ip} ${firewall_dst_port} on ${firewall_delay}" , |
|
399 |
user => 'root', |
|
400 |
project => $name , |
|
401 |
enable => $enable , |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
# Existing files backup |
|
406 |
if ($deploy_root != '') { |
|
407 |
puppi::deploy { "${name}-Backup_Existing_WAR": |
|
408 |
priority => '30' , |
|
409 |
command => 'archive.sh' , |
|
410 |
arguments => "-b ${deploy_root} -t war -s move -m diff -o '${backup_rsync_options}' -n ${backup_retention}" , |
|
411 |
user => 'root' , |
|
412 |
project => $name , |
|
413 |
enable => $enable , |
|
414 |
} |
|
415 |
} |
|
416 |
|
|
417 |
if ($jar_root != '') { |
|
418 |
puppi::deploy { "${name}-Backup_Existing_JAR": |
|
419 |
priority => '30' , |
|
420 |
command => 'archive.sh' , |
|
421 |
arguments => "-b ${jar_root} -t jar -s move -m diff -o '${backup_rsync_options}' -n ${backup_retention}" , |
|
422 |
user => 'root' , |
|
423 |
project => $name , |
|
424 |
enable => $enable , |
|
425 |
} |
|
426 |
} |
|
427 |
|
|
428 |
if ($config_root != '') { |
|
429 |
puppi::deploy { "${name}-Backup_Existing_ConfigDir": |
|
430 |
priority => '30' , |
|
431 |
command => 'archive.sh' , |
|
432 |
arguments => "-b ${config_root} -t config -d predeploydir_configfile -o '${backup_rsync_options}' -n ${backup_retention}" , |
|
433 |
user => 'root' , |
|
434 |
project => $name , |
|
435 |
enable => $enable , |
|
436 |
} |
|
437 |
} |
|
438 |
|
|
439 |
if ($document_root != '') { |
|
440 |
puppi::deploy { "${name}-Backup_Existing_DocumentDir": |
|
441 |
priority => '30' , |
|
442 |
command => 'archive.sh' , |
|
443 |
arguments => "-b ${document_root} -t docroot -d predeploydir_configfile -o '${backup_rsync_options}' -n ${backup_retention}" , |
|
444 |
user => 'root' , |
|
445 |
project => $name , |
|
446 |
enable => $enable , |
|
447 |
} |
|
448 |
} |
|
449 |
|
|
450 |
if ($zip_root != '') { |
|
451 |
puppi::deploy { "${name}-Backup_Existing_ZipDir": |
|
452 |
priority => '30' , |
|
453 |
command => 'archive.sh' , |
|
454 |
arguments => "-b ${zip_root} -t ziproot -d predeploydir_zipfile -o '${backup_rsync_options}' -n ${backup_retention}" , |
|
455 |
user => 'root' , |
|
456 |
project => $name , |
|
457 |
enable => $enable , |
|
458 |
} |
|
459 |
} |
|
460 |
|
|
461 |
if ($bool_check_deploy == true) and ($deploy_root != '') { |
|
462 |
puppi::deploy { "${name}-Check_undeploy": |
|
463 |
priority => '31' , |
|
464 |
command => 'checkwardir.sh' , |
|
465 |
arguments => "-a ${deploy_root} -c deploy_warpath" , |
|
466 |
user => $user , |
|
467 |
project => $name , |
|
468 |
enable => $enable , |
|
469 |
} |
|
470 |
} |
|
471 |
|
|
472 |
if ($disable_services != '') { |
|
473 |
puppi::deploy { "${name}-Disable_extra_services": |
|
474 |
priority => '36' , |
|
475 |
command => 'service.sh' , |
|
476 |
arguments => "stop ${disable_services}" , |
|
477 |
user => 'root', |
|
478 |
project => $name , |
|
479 |
enable => $enable , |
|
480 |
} |
|
481 |
} |
|
482 |
|
|
483 |
if ($init_script != '') { |
|
484 |
puppi::deploy { "${name}-Service_stop": |
|
485 |
priority => '38' , |
|
486 |
command => 'service.sh' , |
|
487 |
arguments => "stop ${init_script}" , |
|
488 |
user => 'root', |
|
489 |
project => $name , |
|
490 |
enable => $enable , |
|
491 |
} |
|
492 |
} |
|
493 |
|
|
494 |
if ($predeploy_customcommand != '') { |
|
495 |
puppi::deploy { "${name}-Run_Custom_PreDeploy_Script": |
|
496 |
priority => $predeploy_priority , |
|
497 |
command => 'execute.sh' , |
|
498 |
arguments => $predeploy_customcommand , |
|
499 |
user => $predeploy_real_user , |
|
500 |
project => $name , |
|
501 |
enable => $enable , |
|
502 |
} |
|
503 |
} |
|
504 |
|
|
505 |
# Deploys |
|
506 |
if ($deploy_root != '') { |
|
507 |
puppi::deploy { "${name}-Deploy_Maven_WAR": |
|
508 |
priority => '40' , |
|
509 |
command => 'deploy.sh' , |
|
510 |
arguments => $deploy_root , |
|
511 |
user => $user , |
|
512 |
project => $name , |
|
513 |
enable => $enable , |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
if ($jar_root != '') { |
|
518 |
puppi::deploy { "${name}-Deploy_Maven_JAR": |
|
519 |
priority => '40' , |
|
520 |
command => 'deploy.sh' , |
|
521 |
arguments => $jar_root , |
|
522 |
user => $jar_real_user , |
|
523 |
project => $name , |
|
524 |
enable => $enable , |
|
525 |
} |
|
526 |
} |
|
527 |
|
|
528 |
if ($config_root != '') { |
|
529 |
puppi::deploy { "${name}-Deploy_ConfigDir": |
|
530 |
priority => '40' , |
|
531 |
command => 'deploy.sh' , |
|
532 |
arguments => "${config_root} predeploydir_configfile" , |
|
533 |
user => $config_real_user , |
|
534 |
project => $name , |
|
535 |
enable => $enable , |
|
536 |
} |
|
537 |
} |
|
538 |
|
|
539 |
if ($document_root != '') { |
|
540 |
puppi::deploy { "${name}-Deploy_DocumentDir": |
|
541 |
priority => '40' , |
|
542 |
command => 'deploy.sh' , |
|
543 |
arguments => "${document_root} predeploydir_srcfile" , |
|
544 |
user => $document_real_user , |
|
545 |
project => $name , |
|
546 |
enable => $enable , |
|
547 |
} |
|
548 |
} |
|
549 |
|
|
550 |
if ($zip_root != '') { |
|
551 |
puppi::deploy { "${name}-Deploy_Zip": |
|
552 |
priority => '40' , |
|
553 |
command => 'deploy.sh' , |
|
554 |
arguments => "${zip_root} predeploydir_zipfile" , |
|
555 |
user => $zip_real_user , |
|
556 |
project => $name , |
|
557 |
enable => $enable , |
|
558 |
} |
|
559 |
} |
|
560 |
|
|
561 |
if ($postdeploy_customcommand != '') { |
|
562 |
puppi::deploy { "${name}-Run_Custom_PostDeploy_Script": |
|
563 |
priority => $postdeploy_priority , |
|
564 |
command => 'execute.sh' , |
|
565 |
arguments => $postdeploy_customcommand , |
|
566 |
user => $postdeploy_real_user , |
|
567 |
project => $name , |
|
568 |
enable => $enable , |
|
569 |
} |
|
570 |
} |
|
571 |
|
|
572 |
if ($init_script != '') { |
|
573 |
puppi::deploy { "${name}-Service_start": |
|
574 |
priority => '42' , |
|
575 |
command => 'service.sh' , |
|
576 |
arguments => "start ${init_script}" , |
|
577 |
user => 'root', |
|
578 |
project => $name , |
|
579 |
enable => $enable , |
|
580 |
} |
|
581 |
} |
|
582 |
|
|
583 |
if ($disable_services != '') { |
|
584 |
puppi::deploy { "${name}-Enable_extra_services": |
|
585 |
priority => '44' , |
|
586 |
command => 'service.sh' , |
|
587 |
arguments => "start ${disable_services}" , |
|
588 |
user => 'root', |
|
589 |
project => $name , |
|
590 |
enable => $enable , |
|
591 |
} |
|
592 |
} |
|
593 |
|
|
594 |
if ($bool_check_deploy == true) and ($deploy_root != '') { |
|
595 |
puppi::deploy { "${name}-Check_deploy": |
|
596 |
priority => '45' , |
|
597 |
command => 'checkwardir.sh' , |
|
598 |
arguments => "-p ${deploy_root} -c deploy_warpath" , |
|
599 |
user => $user , |
|
600 |
project => $name , |
|
601 |
enable => $enable , |
|
602 |
} |
|
603 |
} |
|
604 |
|
|
605 |
if ($firewall_src_ip != '') { |
|
606 |
puppi::deploy { "${name}-Load_Balancer_Unblock": |
|
607 |
priority => '46' , |
|
608 |
command => 'firewall.sh' , |
|
609 |
arguments => "${firewall_src_ip} ${firewall_dst_port} off 0" , |
|
610 |
user => 'root', |
|
611 |
project => $name , |
|
612 |
enable => $enable , |
|
613 |
} |
|
614 |
} |
|
615 |
|
|
616 |
if ($bool_run_checks == true) { |
|
617 |
puppi::deploy { "${name}-Run_POST-Checks": |
|
618 |
priority => '80' , |
|
619 |
command => 'check_project.sh' , |
|
620 |
arguments => $name , |
|
621 |
user => 'root' , |
|
622 |
project => $name , |
|
623 |
enable => $enable , |
|
624 |
} |
|
625 |
} |
|
626 |
|
|
627 |
|
|
628 |
### ROLLBACK PROCEDURE |
|
629 |
|
|
630 |
if ($firewall_src_ip != '') { |
|
631 |
puppi::rollback { "${name}-Load_Balancer_Block": |
|
632 |
priority => '25' , |
|
633 |
command => 'firewall.sh' , |
|
634 |
arguments => "${firewall_src_ip} ${firewall_dst_port} on ${firewall_delay}" , |
|
635 |
user => 'root', |
|
636 |
project => $name , |
|
637 |
enable => $enable , |
|
638 |
} |
|
639 |
} |
|
640 |
|
|
641 |
if ($disable_services != '') { |
|
642 |
puppi::rollback { "${name}-Disable_extra_services": |
|
643 |
priority => '37' , |
|
644 |
command => 'service.sh' , |
|
645 |
arguments => "stop ${disable_services}" , |
|
646 |
user => 'root', |
|
647 |
project => $name , |
|
648 |
enable => $enable , |
|
649 |
} |
|
650 |
} |
|
651 |
|
|
652 |
if ($init_script != '') { |
|
653 |
puppi::rollback { "${name}-Service_stop": |
|
654 |
priority => '38' , |
|
655 |
command => 'service.sh' , |
|
656 |
arguments => "stop ${init_script}" , |
|
657 |
user => 'root', |
|
658 |
project => $name , |
|
659 |
enable => $enable , |
|
660 |
} |
|
661 |
} |
|
662 |
|
|
663 |
if ($predeploy_customcommand != '') { |
|
664 |
puppi::rollback { "${name}-Run_Custom_PreDeploy_Script": |
|
665 |
priority => $predeploy_priority , |
|
666 |
command => 'execute.sh' , |
|
667 |
arguments => $predeploy_customcommand , |
|
668 |
user => $predeploy_real_user , |
|
669 |
project => $name , |
|
670 |
enable => $enable , |
|
671 |
} |
|
672 |
} |
|
673 |
|
|
674 |
if ($deploy_root != '') { |
|
675 |
puppi::rollback { "${name}-Recover_WAR": |
|
676 |
priority => '40' , |
|
677 |
command => 'archive.sh' , |
|
678 |
arguments => "-r ${deploy_root} -t war -o '${backup_rsync_options}'" , |
|
679 |
user => $user , |
|
680 |
project => $name , |
|
681 |
enable => $enable , |
|
682 |
} |
|
683 |
} |
|
684 |
|
|
685 |
if ($jar_root != '') { |
|
686 |
puppi::rollback { "${name}-Recover_JAR": |
|
687 |
priority => '40' , |
|
688 |
command => 'archive.sh' , |
|
689 |
arguments => "-r ${jar_root} -t jar -o '${backup_rsync_options}'" , |
|
690 |
user => $jar_real_user , |
|
691 |
project => $name , |
|
692 |
enable => $enable , |
|
693 |
} |
|
694 |
} |
|
695 |
|
|
696 |
if ($config_root != '') { |
|
697 |
puppi::rollback { "${name}-Recover_ConfigDir": |
|
698 |
priority => '40' , |
|
699 |
command => 'archive.sh' , |
|
700 |
arguments => "-r ${config_root} -t config -o '${backup_rsync_options}'" , |
|
701 |
user => $config_real_user , |
|
702 |
project => $name , |
|
703 |
enable => $enable , |
|
704 |
} |
|
705 |
} |
|
706 |
|
|
707 |
if ($document_root != '') { |
|
708 |
puppi::rollback { "${name}-Recover_DocumentDir": |
|
709 |
priority => '40' , |
|
710 |
command => 'archive.sh' , |
|
711 |
arguments => "-r ${document_root} -t docroot -o '${backup_rsync_options}'" , |
|
712 |
user => $document_real_user , |
|
713 |
project => $name , |
|
714 |
enable => $enable , |
|
715 |
} |
|
716 |
} |
|
717 |
|
|
718 |
if ($postdeploy_customcommand != '') { |
|
719 |
puppi::rollback { "${name}-Run_Custom_PostDeploy_Script": |
|
720 |
priority => $postdeploy_priority , |
|
721 |
command => 'execute.sh' , |
|
722 |
arguments => $postdeploy_customcommand , |
|
723 |
user => $postdeploy_real_user , |
|
724 |
project => $name , |
|
725 |
enable => $enable , |
|
726 |
} |
|
727 |
} |
|
728 |
|
|
729 |
if ($init_script != '') { |
|
730 |
puppi::rollback { "${name}-Service_start": |
|
731 |
priority => '42' , |
|
732 |
command => 'service.sh' , |
|
733 |
arguments => "start ${init_script}" , |
|
734 |
user => 'root', |
|
735 |
project => $name , |
|
736 |
enable => $enable , |
|
737 |
} |
|
738 |
} |
|
739 |
|
|
740 |
if ($disable_services != '') { |
|
741 |
puppi::rollback { "${name}-Enable_extra_services": |
|
742 |
priority => '44' , |
|
743 |
command => 'service.sh' , |
|
744 |
arguments => "start ${disable_services}" , |
|
745 |
user => 'root', |
|
746 |
project => $name , |
|
747 |
enable => $enable , |
|
748 |
} |
|
749 |
} |
|
750 |
|
|
751 |
if ($bool_check_deploy == true) { |
|
752 |
puppi::rollback { "${name}-Check_deploy": |
|
753 |
priority => '45' , |
|
754 |
command => 'checkwardir.sh' , |
|
755 |
arguments => "-p ${deploy_root} -c deploy_warpath" , |
|
756 |
user => $user , |
|
757 |
project => $name , |
|
758 |
enable => $enable , |
|
759 |
} |
|
760 |
} |
|
761 |
|
|
762 |
if ($firewall_src_ip != '') { |
|
763 |
puppi::rollback { "${name}-Load_Balancer_Unblock": |
|
764 |
priority => '46' , |
|
765 |
command => 'firewall.sh' , |
|
766 |
arguments => "${firewall_src_ip} ${firewall_dst_port} off 0" , |
|
767 |
user => 'root', |
|
768 |
project => $name , |
|
769 |
enable => $enable , |
|
770 |
} |
|
771 |
} |
|
772 |
|
|
773 |
if ($bool_run_checks == true) { |
|
774 |
puppi::rollback { "${name}-Run_POST-Checks": |
|
775 |
priority => '80' , |
|
776 |
command => 'check_project.sh' , |
|
777 |
arguments => $name , |
|
778 |
user => 'root' , |
|
779 |
project => $name , |
|
780 |
enable => $enable , |
|
781 |
} |
|
782 |
} |
|
783 |
|
|
784 |
|
|
785 |
### REPORTING |
|
786 |
|
|
787 |
if ($report_email != '') { |
|
788 |
puppi::report { "${name}-Mail_Notification": |
|
789 |
priority => '20' , |
|
790 |
command => 'report_mail.sh' , |
|
791 |
arguments => $report_email , |
|
792 |
user => 'root', |
|
793 |
project => $name , |
|
794 |
enable => $enable , |
|
795 |
} |
|
796 |
} |
|
797 |
|
|
798 |
if ($report_mongo != '') { |
|
799 |
puppi::report { "${name}-Mongo_Store": |
|
800 |
priority => '30' , |
|
801 |
command => 'report_mongo.sh' , |
|
802 |
arguments => $report_mongo , |
|
803 |
user => 'root', |
|
804 |
project => $name , |
|
805 |
enable => $enable , |
|
806 |
} |
|
807 |
} |
|
808 |
|
|
809 |
### AUTO DEPLOY DURING PUPPET RUN |
|
810 |
if ($bool_auto_deploy == true) { |
|
811 |
puppi::run { $name: } |
|
812 |
} |
|
813 |
|
|
814 |
} |