diff --git a/.sync.yml b/.sync.yml index da5e3b6..3c963ea 100644 --- a/.sync.yml +++ b/.sync.yml @@ -23,3 +23,7 @@ Rakefile: - '2sp_soft_tabs' - 'arrow_alignment' +.travis.yml: + includes: + - env: PUPPET_GEM_VERSION="= 4.6.1" CHECK=parallel_spec + rvm: 2.1.9 diff --git a/.travis.yml b/.travis.yml index ed27d4d..502a9fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,9 @@ matrix: - env: DEPLOY_TO_FORGE=yes stage: deploy + - + env: PUPPET_GEM_VERSION="= 4.6.1" CHECK=parallel_spec + rvm: 2.1.9 branches: only: - master diff --git a/Gemfile b/Gemfile index 0e6b530..2aeab8e 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ group :development do gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] diff --git a/Rakefile b/Rakefile index 0fd940c..2784ba3 100644 --- a/Rakefile +++ b/Rakefile @@ -15,8 +15,17 @@ end def changelog_project return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1] - raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? + + returnVal = nil + returnVal ||= begin + metadata_source = JSON.load(File.read('metadata.json'))['source'] + metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) + + metadata_source_match && metadata_source_match[1] + end + + raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator project:#{returnVal}" returnVal end diff --git a/manifests/maintenance/pg_repack.pp b/manifests/maintenance/pg_repack.pp index e894c33..32b2e6d 100644 --- a/manifests/maintenance/pg_repack.pp +++ b/manifests/maintenance/pg_repack.pp @@ -7,6 +7,7 @@ class pe_databases::maintenance::pg_repack ( Boolean $disable_maintenance = $pe_databases::maintenance::disable_maintenance, String $logging_directory = $pe_databases::maintenance::logging_directory, + Integer $jobs = $facts['processors']['count']/4 ) { $ensure_cron = $disable_maintenance ? { @@ -14,11 +15,21 @@ default => present } - $repack = 'su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/bin/pg_repack -d pe-puppetdb' + #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 + $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" } + + $repack = "su - pe-postgres -s /bin/bash -c \"${repack_executable} -d pe-puppetdb" + $repack_jobs = "--jobs ${jobs}" $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"' + $reports_tables = versioncmp('2019.1.0', $facts['pe_server_version']) ? { + 1 => '-t reports"', + default => '-t reports -t resource_events"' } $logging = "> ${logging_directory}/output.log 2>&1" Cron { @@ -31,21 +42,21 @@ weekday => [2,6], hour => 4, minute => 30, - command => "${repack} ${facts_tables} ${logging}", + command => "${repack} ${repack_jobs} ${facts_tables} ${logging}", } cron { 'pg_repack catalogs tables' : weekday => [0,4], hour => 4, minute => 30, - command => "${repack} ${catalogs_tables} ${logging}", + command => "${repack} ${repack_jobs} ${catalogs_tables} ${logging}", } cron { 'pg_repack other tables' : monthday => 20, hour => 5, minute => 30, - command => "${repack} ${other_tables} ${logging}", + command => "${repack} ${repack_jobs} ${other_tables} ${logging}", } cron { 'pg_repack reports tables' : @@ -54,6 +65,6 @@ monthday => 10, hour => 5, minute => 30, - command => "${repack} ${reports_tables} ${logging}", + command => "${repack} ${repack_jobs} ${reports_tables} ${logging}", } } diff --git a/metadata.json b/metadata.json index 972784b..0cfa04a 100644 --- a/metadata.json +++ b/metadata.json @@ -76,7 +76,7 @@ "version_requirement": ">= 4.0" } ], - "pdk-version": "1.11.1 (heads/master-0-g4f00e4a)", + "pdk-version": "1.14.0.pre (heads/master-0-g9158517)", "template-url": "https://github.com/npwalker/pdk-templates#add_circleci_and_azure_pipelines_support", - "template-ref": "remotes/origin/add_circleci_and_azure_pipelines_support-0-gd24cef7" + "template-ref": "remotes/origin/add_circleci_and_azure_pipelines_support-0-gdc89556" } diff --git a/spec/classes/maintenance/pg_repack_spec.rb b/spec/classes/maintenance/pg_repack_spec.rb index a0014e1..4062666 100644 --- a/spec/classes/maintenance/pg_repack_spec.rb +++ b/spec/classes/maintenance/pg_repack_spec.rb @@ -7,6 +7,50 @@ let(:facts) { os_facts } it { is_expected.to compile } + context 'on PE 2019.1.0' do + before :each do + facts['pe_server_version'] = '2019.1.0' + facts['pe_postgresql_info']['installed_server_version'] = 9.6 + end + it { + is_expected.to contain_cron('pg_repack reports tables') + .with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/9.6/bin/pg_repack'\ + ' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1') + } + end + context 'on > PE 2019.1.0' do + before :each do + facts['pe_server_version'] = '2019.2.0' + facts['pe_postgresql_info']['installed_server_version'] = 9.6 + end + it { + is_expected.to contain_cron('pg_repack reports tables') + .with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/9.6/bin/pg_repack'\ + ' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1') + } + end + context 'on < PE 2019.1.0' do + before :each do + facts['pe_server_version'] = '2019.0.0' + facts['pe_postgresql_info']['installed_server_version'] = 9.6 + end + it { + is_expected.to contain_cron('pg_repack reports tables') + .with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/bin/pg_repack'\ + ' -d pe-puppetdb --jobs 2 -t reports" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1') + } + end + context 'on > PE 2019.1.0 with postgresql 11' do + before :each do + facts['pe_server_version'] = '2019.2.0' + facts['pe_postgresql_info']['installed_server_version'] = 11 + end + it { + is_expected.to contain_cron('pg_repack reports tables') + .with_command('su - pe-postgres -s /bin/bash -c "/opt/puppetlabs/server/apps/postgresql/11/bin/pg_repack'\ + ' -d pe-puppetdb --jobs 2 -t reports -t resource_events" > /var/log/puppetlabs/pe_databases_cron/output.log 2>&1') + } + end end end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 1a1b5d3..ba76245 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -12,4 +12,6 @@ memory: total_bytes: 17179869184 processors: count: 8 +pe_postgresql_info: + installed_server_version: 9.6