|
1 | 1 | class pe_databases::maintenance ( |
2 | | - Boolean $disable_maintenace = false, |
3 | | - Optional[Integer] $maint_cron_weekday = undef, #DEPRECATED |
4 | | - Optional[Integer] $maint_cron_hour = undef, #DEPRECATED |
5 | | - Optional[Integer] $maint_cron_minute = undef, #DEPRECATED |
| 2 | + Boolean $disable_maintenance = false, |
6 | 3 | String $logging_directory = '/var/log/puppetlabs/pe_databases_cron', |
7 | 4 | String $script_directory = $pe_databases::scripts_dir, |
8 | 5 | ){ |
9 | 6 |
|
10 | | - $ensure_cron = $disable_maintenace ? { |
11 | | - true => absent, |
12 | | - default => present |
| 7 | + #If the PE Version includes pg_repack (2018.1.7 and 2019.0.2) then use pg_repack and remove the old script and cron jobs |
| 8 | + if ( versioncmp( '2018.1.7', $facts['pe_server_version']) <= 0 and versioncmp($facts['pe_server_version'], '2019.0.0') < 0 ) { |
| 9 | + include pe_databases::maintenance::pg_repack |
| 10 | + class { 'pe_databases::maintenance::vacuum_full': |
| 11 | + disable_maintenance => true, |
| 12 | + } |
| 13 | + } elsif ( versioncmp( '2019.0.2', $facts['pe_server_version']) <= 0 ) { |
| 14 | + include pe_databases::maintenance::pg_repack |
| 15 | + class { 'pe_databases::maintenance::vacuum_full': |
| 16 | + disable_maintenance => true, |
| 17 | + } |
| 18 | + } else { |
| 19 | + include pe_databases::maintenance::vacuum_full |
13 | 20 | } |
14 | 21 |
|
15 | 22 | file { $logging_directory : |
16 | 23 | ensure => directory, |
17 | 24 | } |
18 | | - |
19 | | - $vacuum_script_path = "${script_directory}/vacuum_full_tables.sh" |
20 | | - |
21 | | - file { $vacuum_script_path: |
22 | | - ensure => file, |
23 | | - source => 'puppet:///modules/pe_databases/vacuum_full_tables.sh', |
24 | | - owner => 'pe-postgres', |
25 | | - group => 'pe-postgres', |
26 | | - mode => '0744', |
27 | | - } |
28 | | - |
29 | | - cron { 'VACUUM FULL facts tables' : |
30 | | - ensure => $ensure_cron, |
31 | | - user => 'root', |
32 | | - weekday => [2,6], |
33 | | - hour => 4, |
34 | | - minute => 30, |
35 | | - command => "${vacuum_script_path} facts", |
36 | | - require => File[$logging_directory, $script_directory], |
37 | | - } |
38 | | - |
39 | | - cron { 'VACUUM FULL catalogs tables' : |
40 | | - ensure => $ensure_cron, |
41 | | - user => 'root', |
42 | | - weekday => [0,4], |
43 | | - hour => 4, |
44 | | - minute => 30, |
45 | | - command => "${vacuum_script_path} catalogs", |
46 | | - require => File[$logging_directory, $script_directory], |
47 | | - } |
48 | | - |
49 | | - cron { 'VACUUM FULL other tables' : |
50 | | - ensure => $ensure_cron, |
51 | | - user => 'root', |
52 | | - monthday => 20, |
53 | | - hour => 5, |
54 | | - minute => 30, |
55 | | - command => "${vacuum_script_path} other", |
56 | | - require => File[$logging_directory, $script_directory], |
57 | | - } |
58 | | - |
59 | | - #Remove old versions of maintenance cron jobs |
60 | | - cron { 'Maintain PE databases' : |
61 | | - ensure => absent, |
62 | | - user => 'root', |
63 | | - weekday => $maint_cron_weekday, |
64 | | - hour => $maint_cron_hour, |
65 | | - minute => $maint_cron_minute, |
66 | | - command => "su - pe-postgres -s /bin/bash -c '/opt/puppetlabs/server/bin/reindexdb --all; /opt/puppetlabs/server/bin/vacuumdb --analyze --verbose --all' > ${logging_directory}/output.log 2> ${logging_directory}/output_error.log", |
67 | | - require => File[$logging_directory, $script_directory], |
68 | | - } |
69 | | - |
70 | | - if empty($maint_cron_weekday) == false { |
71 | | - warning('pe_databases::maintenance::maint_cron_weekday is deprecated and will be removed in a future release') |
72 | | - } |
73 | | - if empty($maint_cron_hour) == false { |
74 | | - warning('pe_databases::maintenance::maint_cron_hour is deprecated and will be removed in a future release') |
75 | | - } |
76 | | - if empty($maint_cron_minute) == false { |
77 | | - warning('pe_databases::maintenance::maint_cron_minute is deprecated and will be removed in a future release') |
78 | | - } |
79 | 25 | } |
0 commit comments