Skip to content

fix puppet lint warnings #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions manifests/collect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Boolean $disable_maintenance = false,
String $on_cal = undef,
) {

Service {
notify => Exec['pe_databases_daemon_reload'],
}
Expand All @@ -28,11 +27,11 @@
default => present
}

file {"/etc/systemd/system/pe_databases-${database_type}.service":
file { "/etc/systemd/system/pe_databases-${database_type}.service":
ensure => $ensure_file,
content => epp('pe_databases/service.epp', { 'tables' => $database_type, 'command' => $command }),
}
file {"/etc/systemd/system/pe_databases-${database_type}.timer":
file { "/etc/systemd/system/pe_databases-${database_type}.timer":
ensure => $ensure_file,
content => epp('pe_databases/timer.epp', { 'tables' => $database_type, 'on_cal' => $on_cal }),
}
Expand Down
12 changes: 5 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @summary Tuning, maintenance for PE PostgreSQL.
#
# @param manage_database_maintenance [Boolean] true or false (Default: true)
# Manage the inclusion of the pg_repack class
# @param disable_maintenance [Boolean] true or false (Default: false)
# Disable or enable maintenance mode
# @param manage_postgresql_settings [Boolean] true or false (Default: true)
Expand All @@ -9,22 +11,19 @@
# @param install_dir [String] Directory to install module into (Default: "/opt/puppetlabs/pe_databases")
# @param scripts_dir [String] Directory to install scripts into (Default: "${install_dir}/scripts")
class pe_databases (
# Manage the inclusion of the pg_repack class
Boolean $manage_database_maintenance = true,
# Manage the state of the maintenance tasks, i.e. systemd services and timers
Boolean $disable_maintenance = lookup('pe_databases::disable_maintenance', {'default_value' => false}),
Boolean $disable_maintenance = false,
Boolean $manage_postgresql_settings = true,
Boolean $manage_table_settings = false,
String $install_dir = '/opt/puppetlabs/pe_databases',
String $scripts_dir = "${install_dir}/scripts"
) {

$psql_version = $facts['pe_postgresql_info']['installed_server_version'] ? {
undef => undef,
default => String($facts['pe_postgresql_info']['installed_server_version'])
}

file { [$install_dir, $scripts_dir] :
file { [$install_dir, $scripts_dir]:
ensure => directory,
mode => '0755',
}
Expand All @@ -38,7 +37,7 @@
if $facts.dig('pe_databases', 'have_systemd') {
if versioncmp('2019.0.2', $facts['pe_server_version']) <= 0 {
if $manage_database_maintenance {
class {'pe_databases::pg_repack':
class { 'pe_databases::pg_repack':
disable_maintenance => $disable_maintenance,
}
if $manage_table_settings {
Expand All @@ -48,7 +47,6 @@
include pe_databases::postgresql_settings::table_settings
}
}

}
else {
notify { 'pe_databases_version_warn':
Expand Down
23 changes: 11 additions & 12 deletions manifests/pg_repack.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,54 @@
Boolean $disable_maintenance = false,
Integer $jobs = $facts['processors']['count'] / 4
) {

# PE 2019.1 starting shipping versioned pe-postgres packages where all paths are versioned.
# So, prior to 2019.1 use a non-versioned path, and after use a versioned path.
# TODO: Use $pe_databases::psql_version after identifying why it is cast to ${psql_version}00000 in spec tests.
$postgresql_version = $facts['pe_postgresql_info']['installed_server_version']
$repack_executable = versioncmp('2019.1.0', $facts['pe_server_version']) ? {
1 => '/opt/puppetlabs/server/apps/postgresql/bin/pg_repack',
default => "/opt/puppetlabs/server/apps/postgresql/${postgresql_version}/bin/pg_repack"
}
1 => '/opt/puppetlabs/server/apps/postgresql/bin/pg_repack',
default => "/opt/puppetlabs/server/apps/postgresql/${postgresql_version}/bin/pg_repack"
}

$repack = "${repack_executable} -d pe-puppetdb"
$repack_jobs = "--jobs ${jobs}"

$facts_tables = '-t factsets -t fact_paths'
$catalogs_tables = versioncmp($facts['pe_server_version'], '2019.8.1') ? {
1 => '-t catalogs -t catalog_resources -t catalog_inputs -t edges -t certnames',
default => '-t catalogs -t catalog_resources -t edges -t certnames' }
1 => '-t catalogs -t catalog_resources -t catalog_inputs -t edges -t certnames',
default => '-t catalogs -t catalog_resources -t edges -t certnames' }
$other_tables = '-t producers -t resource_params -t resource_params_cache'
$reports_table = '-t reports'
$resource_events_table = '-t resource_events'

pe_databases::collect {'facts':
pe_databases::collect { 'facts':
disable_maintenance => $disable_maintenance,
command => "${repack} ${repack_jobs} ${facts_tables}",
on_cal => 'Tue,Sat *-*-* 04:30:00',
}

pe_databases::collect {'catalogs':
pe_databases::collect { 'catalogs':
disable_maintenance => $disable_maintenance,
command => "${repack} ${repack_jobs} ${catalogs_tables}",
on_cal => 'Sun,Thu *-*-* 04:30:00',
}

pe_databases::collect {'other':
pe_databases::collect { 'other':
disable_maintenance => $disable_maintenance,
command => "${repack} ${repack_jobs} ${other_tables}",
on_cal => '*-*-20 05:30:00',
}

if versioncmp($facts['pe_server_version'], '2019.7.0') < 0 {
pe_databases::collect {'reports':
pe_databases::collect { 'reports':
disable_maintenance => $disable_maintenance,
command => "${repack} ${repack_jobs} ${reports_table}",
on_cal => '*-*-10 05:30:00',
}
}

if versioncmp($facts['pe_server_version'], '2019.3.0') < 0 {
pe_databases::collect {'resource_events':
pe_databases::collect { 'resource_events':
disable_maintenance => $disable_maintenance,
command => "${repack} ${repack_jobs} ${resource_events_table}",
on_cal => '*-*-15 05:30:00',
Expand All @@ -78,6 +77,6 @@
'Maintain PE databases',
]
cron { $legacy_crons:
ensure => absent,
ensure => absent,
}
}
13 changes: 6 additions & 7 deletions manifests/postgresql_settings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
Optional[Float[0,1]] $factsets_autovacuum_vacuum_scale_factor = 0.80,
Optional[Float[0,1]] $reports_autovacuum_vacuum_scale_factor = 0.01,
String $maintenance_work_mem = $all_in_one_pe_install ? {
false => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 3}MB",
true => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 8}MB",
},
false => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 3}MB",
true => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 8}MB",
},
String $autovacuum_work_mem = $all_in_one_pe_install ? {
false => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 3 / $autovacuum_max_workers}MB",
true => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 8 / $autovacuum_max_workers}MB",
},
false => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 3 / $autovacuum_max_workers}MB",
true => "${facts['memory']['system']['total_bytes'] / 1024 / 1024 / 8 / $autovacuum_max_workers}MB",
},
String $psql_version = $pe_databases::psql_version,
# lint:endignore
) {

$postgresql_service_resource_name = 'postgresqld'
$postgresql_service_name = 'pe-postgresql'
$notify_postgresql_service = $manage_postgresql_service ? {
Expand Down
7 changes: 3 additions & 4 deletions manifests/postgresql_settings/table_settings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
#
class pe_databases::postgresql_settings::table_settings (
# lint:ignore:140chars
Boolean $manage_reports_autovacuum_cost_delay = lookup('pe_databases::postgresql_settings::manage_reports_autovacuum_cost_delay', {'default_value' => true}),
Optional[Float[0,1]] $factsets_autovacuum_vacuum_scale_factor = lookup('pe_databases::postgresql_settings::factsets_autovacuum_vacuum_scale_factor', {'default_value' => 0.80}),
Optional[Float[0,1]] $reports_autovacuum_vacuum_scale_factor = lookup('pe_databases::postgresql_settings::reports_autovacuum_vacuum_scale_factor', {'default_value' => 0.01}),
Boolean $manage_reports_autovacuum_cost_delay = lookup('pe_databases::postgresql_settings::manage_reports_autovacuum_cost_delay', { 'default_value' => true }),
Optional[Float[0,1]] $factsets_autovacuum_vacuum_scale_factor = lookup('pe_databases::postgresql_settings::factsets_autovacuum_vacuum_scale_factor', { 'default_value' => 0.80 }),
Optional[Float[0,1]] $reports_autovacuum_vacuum_scale_factor = lookup('pe_databases::postgresql_settings::reports_autovacuum_vacuum_scale_factor', { 'default_value' => 0.01 }),
Optional[Float[0,1]] $catalogs_autovacuum_vacuum_scale_factor = 0.75,
Optional[Float[0,1]] $certnames_autovacuum_vacuum_scale_factor = 0.75,
# lint:endignore
) {

if $manage_reports_autovacuum_cost_delay {
pe_databases::set_puppetdb_table_autovacuum_cost_delay_zero { 'reports' : }
}
Expand Down
1 change: 0 additions & 1 deletion manifests/set_puppetdb_table_autovacuum_cost_delay_zero.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
define pe_databases::set_puppetdb_table_autovacuum_cost_delay_zero (
String $table_name = $title,
) {

pe_databases::set_table_attribute { "Set autovacuum_cost_delay=0 for ${table_name}" :
db => 'pe-puppetdb',
table_name => $table_name,
Expand Down
1 change: 0 additions & 1 deletion manifests/set_table_attribute.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
String $table_attribute,
String $table_attribute_value,
) {

# lint:ignore:140chars
pe_postgresql_psql { "Set ${table_attribute}=${table_attribute_value} for ${table_name}" :
command => "ALTER TABLE ${table_name} SET ( ${table_attribute} = ${table_attribute_value} )",
Expand Down