Skip to content

Commit b6ef64d

Browse files
committed
Fix managing backup class and resources
Prior to this commit, the ensure for the cron entries in the backup class were hard coded to 'present' and could not be removed once set. This commit adds a new parameter to manage the cron jobs based on if $manage_database_backups is set. Restructure if/else logic Prior to this commit, the checks for managing the databases and having systemd were done in the same check, so the warning was confusing. This commit moves $manage_database_maintenance to its own if clause. It also moves the $manage_database_backups inside the version check if, because it makes more sense to put all of the resources behind the version check.
1 parent 344d5fa commit b6ef64d

File tree

8 files changed

+28
-35
lines changed

8 files changed

+28
-35
lines changed

.github/workflows/pe_latest_testing.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ jobs:
5353
- name: Setup Acceptance Test Matrix
5454
id: get-matrix
5555
run: |
56-
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"},{\"label\":\"RedHat-8\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-8\"}],\"collection\":[\"2021.2.0\"]}"
57-
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2021.1.0\"]}"
5857
- name: "Honeycomb: Record Setup Test Matrix time"
5958
if: ${{ always() }}
6059
run: |

.github/workflows/pe_lts_testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup Acceptance Test Matrix
5454
id: get-matrix
5555
run: |
56-
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-7\",\"provider\":\"provision::provision_service\",\"image\":\"centos-7\"},{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"RedHat-7\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-7\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"},{\"label\":\"RedHat-8\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-8\"}],\"collection\":[\"2019.8.7\"]}"
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-7\",\"provider\":\"provision::provision_service\",\"image\":\"centos-7\"},{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"RedHat-7\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-7\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2019.8.6\"]}"
5757
- name: "Honeycomb: Record Setup Test Matrix time"
5858
if: ${{ always() }}
5959
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/spec/fixtures/litmus_inventory.yaml

.pdkignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/spec/fixtures/litmus_inventory.yaml
2928
/appveyor.yml
30-
/.editorconfig
3129
/.fixtures.yml
3230
/Gemfile
3331
/.gitattributes

manifests/backup.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
String $daily_databases_path = "${pe_databases::install_dir}/default_daily_databases.txt",
3030
String $backup_logging_directory = '/var/log/puppetlabs/pe_databases_backup',
3131
Integer $retention_policy = 2,
32+
Boolean $disable_maintenance = true,
3233
) {
3334

3435
file { $backup_logging_directory :
@@ -62,6 +63,11 @@
6263
refreshonly => true,
6364
}
6465

66+
$cron_ensure = $disable_maintenance ? {
67+
false => 'present',
68+
default => 'absent',
69+
}
70+
6571
# Since the cron job titles below include the array ('databases') of database names,
6672
# the crontab for pe-postgres needs to be reset if the array of database names changes,
6773
# otherwise the change create a new cron job and unmanage the old cron job.
@@ -72,7 +78,7 @@
7278
$databases_to_backup = $database_backup_set['databases']
7379
$databases = join($databases_to_backup, ' ')
7480
cron { "puppet_enterprise_database_backup_${databases_to_backup}":
75-
ensure => present,
81+
ensure => $cron_ensure,
7682
command => "${backup_script_path} -l ${backup_logging_directory} -t ${backup_directory} -r ${retention_policy} ${databases}",
7783
user => 'pe-postgres',
7884
minute => $database_backup_set['schedule']['minute'],

manifests/init.pp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @summary Tuning, maintenance, and backups for PE PostgreSQL.
44

55
class pe_databases (
6-
Boolean $manage_database_backups = false,
6+
Variant[Boolean,Undef] $manage_database_backups = undef,
77
# Manage the inclusion of the pg_repack class
88
Boolean $manage_database_maintenance = true,
99
# Manage the state of the maintenance tasks, i.e. systemd services and timers
@@ -31,19 +31,22 @@
3131
}
3232

3333
if $facts.dig('pe_databases', 'have_systemd') {
34-
if $manage_database_maintenance and (versioncmp('2019.0.2', $facts['pe_server_version']) <= 0) {
35-
class {'pe_databases::pg_repack':
36-
disable_maintenance => $disable_maintenance,
34+
if versioncmp('2019.0.2', $facts['pe_server_version']) <= 0 {
35+
if $manage_database_maintenance {
36+
class {'pe_databases::pg_repack':
37+
disable_maintenance => $disable_maintenance,
38+
}
39+
if $manage_table_settings {
40+
# This is to provide for situations, like PE XL,
41+
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
42+
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
43+
include pe_databases::postgresql_settings::table_settings
44+
}
3745
}
38-
if $manage_table_settings {
39-
# This is to provide for situations, like PE XL,
40-
# where the pe-puppetdb database does not exist on the PostgreSQL system being tuned.
41-
# In PE XL, the Master and Replica run PostgreSQL for all databases *except* for pe-puppetdb.
42-
include pe_databases::postgresql_settings::table_settings
43-
}
44-
45-
if $manage_database_backups {
46-
include pe_databases::backup
46+
if defined('$manage_database_backups') {
47+
class { 'pe_databases::backup':
48+
disable_maintenance => ! $manage_database_backups,
49+
}
4750
}
4851
}
4952
else {

metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"version_requirement": ">= 5.5.0 < 8.0.0"
5454
}
5555
],
56-
"pdk-version": "2.1.1",
57-
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.1",
58-
"template-ref": "tags/2.1.1-0-g03daa92"
56+
"pdk-version": "2.1.0",
57+
"template-url": "https://github.com/puppetlabs/pdk-templates#2.1.0",
58+
"template-ref": "tags/2.1.0-0-ga675ea5"
5959
}

spec/spec_helper.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@
4848
c.after(:suite) do
4949
RSpec::Puppet::Coverage.report!(0)
5050
end
51-
52-
# Filter backtrace noise
53-
backtrace_exclusion_patterns = [
54-
%r{spec_helper},
55-
%r{gems},
56-
]
57-
58-
if c.respond_to?(:backtrace_exclusion_patterns)
59-
c.backtrace_exclusion_patterns = backtrace_exclusion_patterns
60-
elsif c.respond_to?(:backtrace_clean_patterns)
61-
c.backtrace_clean_patterns = backtrace_exclusion_patterns
62-
end
6351
end
6452

6553
# Ensures that a module is defined

0 commit comments

Comments
 (0)