-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from npwalker/use_pg_repack
Add pg_repack as default maintenance strategy
- Loading branch information
Showing
16 changed files
with
254 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.rb eol=lf | ||
*.erb eol=lf | ||
*.pp eol=lf | ||
*.sh eol=lf | ||
*.epp eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--relative | ||
--no-2sp_soft_tabs-check | ||
--no-arrow_alignment-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,25 @@ | ||
class pe_databases::maintenance ( | ||
Boolean $disable_maintenace = false, | ||
Optional[Integer] $maint_cron_weekday = undef, #DEPRECATED | ||
Optional[Integer] $maint_cron_hour = undef, #DEPRECATED | ||
Optional[Integer] $maint_cron_minute = undef, #DEPRECATED | ||
Boolean $disable_maintenance = false, | ||
String $logging_directory = '/var/log/puppetlabs/pe_databases_cron', | ||
String $script_directory = $pe_databases::scripts_dir, | ||
){ | ||
|
||
$ensure_cron = $disable_maintenace ? { | ||
true => absent, | ||
default => present | ||
#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 | ||
if ( versioncmp( '2018.1.7', $facts['pe_server_version']) <= 0 and versioncmp($facts['pe_server_version'], '2019.0.0') < 0 ) { | ||
include pe_databases::maintenance::pg_repack | ||
class { 'pe_databases::maintenance::vacuum_full': | ||
disable_maintenance => true, | ||
} | ||
} elsif ( versioncmp( '2019.0.2', $facts['pe_server_version']) <= 0 ) { | ||
include pe_databases::maintenance::pg_repack | ||
class { 'pe_databases::maintenance::vacuum_full': | ||
disable_maintenance => true, | ||
} | ||
} else { | ||
include pe_databases::maintenance::vacuum_full | ||
} | ||
|
||
file { $logging_directory : | ||
ensure => directory, | ||
} | ||
|
||
$vacuum_script_path = "${script_directory}/vacuum_full_tables.sh" | ||
|
||
file { $vacuum_script_path: | ||
ensure => file, | ||
source => 'puppet:///modules/pe_databases/vacuum_full_tables.sh', | ||
owner => 'pe-postgres', | ||
group => 'pe-postgres', | ||
mode => '0744', | ||
} | ||
|
||
cron { 'VACUUM FULL facts tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
weekday => [2,6], | ||
hour => 4, | ||
minute => 30, | ||
command => "${vacuum_script_path} facts", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
cron { 'VACUUM FULL catalogs tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
weekday => [0,4], | ||
hour => 4, | ||
minute => 30, | ||
command => "${vacuum_script_path} catalogs", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
cron { 'VACUUM FULL other tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
monthday => 20, | ||
hour => 5, | ||
minute => 30, | ||
command => "${vacuum_script_path} other", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
#Remove old versions of maintenance cron jobs | ||
cron { 'Maintain PE databases' : | ||
ensure => absent, | ||
user => 'root', | ||
weekday => $maint_cron_weekday, | ||
hour => $maint_cron_hour, | ||
minute => $maint_cron_minute, | ||
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", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
if empty($maint_cron_weekday) == false { | ||
warning('pe_databases::maintenance::maint_cron_weekday is deprecated and will be removed in a future release') | ||
} | ||
if empty($maint_cron_hour) == false { | ||
warning('pe_databases::maintenance::maint_cron_hour is deprecated and will be removed in a future release') | ||
} | ||
if empty($maint_cron_minute) == false { | ||
warning('pe_databases::maintenance::maint_cron_minute is deprecated and will be removed in a future release') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# A description of what this class does | ||
# | ||
# @summary A short summary of the purpose of this class | ||
# | ||
# @example | ||
# include pe_databases::maintenance::pg_repack | ||
class pe_databases::maintenance::pg_repack ( | ||
Boolean $disable_maintenance = $pe_databases::maintenance::disable_maintenance, | ||
String $logging_directory = $pe_databases::maintenance::logging_directory, | ||
) { | ||
|
||
$ensure_cron = $disable_maintenance ? { | ||
true => absent, | ||
default => present | ||
} | ||
|
||
$repack = 'su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/bin/pg_repack -d pe-puppetdb' | ||
$facts_tables = '-t factsets -t fact_paths"' | ||
$catalogs_tables = '-t catalogs -t catalog_resources -t edges -t certnames"' | ||
$other_tables = '-t producers -t resource_params -t resource_params_cache"' | ||
$reports_tables = '-t reports"' | ||
$logging = "> ${logging_directory}/output.log 2>&1" | ||
|
||
Cron { | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
require => File[$logging_directory], | ||
} | ||
|
||
cron { 'pg_repack facts tables' : | ||
weekday => [2,6], | ||
hour => 4, | ||
minute => 30, | ||
command => "${repack} ${facts_tables} ${logging}", | ||
} | ||
|
||
cron { 'pg_repack catalogs tables' : | ||
weekday => [0,4], | ||
hour => 4, | ||
minute => 30, | ||
command => "${repack} ${catalogs_tables} ${logging}", | ||
} | ||
|
||
cron { 'pg_repack other tables' : | ||
monthday => 20, | ||
hour => 5, | ||
minute => 30, | ||
command => "${repack} ${other_tables} ${logging}", | ||
} | ||
|
||
cron { 'pg_repack reports tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
monthday => 10, | ||
hour => 5, | ||
minute => 30, | ||
command => "${repack} ${reports_tables} ${logging}", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# A description of what this class does | ||
# | ||
# @summary A short summary of the purpose of this class | ||
# | ||
# @example | ||
# include pe_databases::maintenance::vacuum_full | ||
class pe_databases::maintenance::vacuum_full ( | ||
Boolean $disable_maintenance = $pe_databases::maintenance::disable_maintenance, | ||
String $logging_directory = $pe_databases::maintenance::logging_directory, | ||
String $script_directory = $pe_databases::maintenance::script_directory, | ||
){ | ||
|
||
$ensure_cron = $disable_maintenance ? { | ||
true => absent, | ||
default => present | ||
} | ||
|
||
$ensure_vacuum_script = $disable_maintenance ? { | ||
true => absent, | ||
default => file | ||
} | ||
|
||
$vacuum_script_path = "${script_directory}/vacuum_full_tables.sh" | ||
|
||
file { $vacuum_script_path: | ||
ensure => $ensure_vacuum_script, | ||
source => 'puppet:///modules/pe_databases/vacuum_full_tables.sh', | ||
owner => 'pe-postgres', | ||
group => 'pe-postgres', | ||
mode => '0744', | ||
} | ||
|
||
cron { 'VACUUM FULL facts tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
weekday => [2,6], | ||
hour => 4, | ||
minute => 30, | ||
command => "${vacuum_script_path} facts", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
cron { 'VACUUM FULL catalogs tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
weekday => [0,4], | ||
hour => 4, | ||
minute => 30, | ||
command => "${vacuum_script_path} catalogs", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
cron { 'VACUUM FULL other tables' : | ||
ensure => $ensure_cron, | ||
user => 'root', | ||
monthday => 20, | ||
hour => 5, | ||
minute => 30, | ||
command => "${vacuum_script_path} other", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
|
||
#Remove old versions of maintenance cron jobs | ||
cron { 'Maintain PE databases' : | ||
ensure => absent, | ||
user => 'root', | ||
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", | ||
require => File[$logging_directory, $script_directory], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'spec_helper' | ||
|
||
describe 'pe_databases::maintenance::pg_repack' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:pre_condition) { "class { 'pe_databases': }" } | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'spec_helper' | ||
|
||
describe 'pe_databases::maintenance::vacuum_full' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:pre_condition) { "class { 'pe_databases': }" } | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
end | ||
end | ||
end |
Oops, something went wrong.