Skip to content
Draft
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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ jobs:
Acceptance:
needs: Spec
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
with:
runs_on: "ubuntu-24.04"
secrets: "inherit"
2 changes: 0 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ jobs:
Acceptance:
needs: Spec
uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main"
with:
runs_on: "ubuntu-24.04"
secrets: "inherit"
8 changes: 8 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
--fail-on-warnings
--relative
--no-80chars-check
--no-140chars-check
--no-class_inherits_from_params_class-check
--no-autoloader_layout-check
--no-documentation-check
--no-single_quote_string_with_variables-check
--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp
--no-anchor_resource-check
--no-params_empty_string_assignment-check
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:
AllCops:
NewCops: enable
DisplayCopNames: true
TargetRubyVersion: '2.6'
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
Expand Down
38 changes: 22 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ def location_for(place_or_version, fake_version = nil)
end

group :development do
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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do lint for ruby 3.1 as a target, so everything will fail on ruby 3.0 anyways and the condition isn't required?

gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "deep_merge", '~> 1.2.2', require: false
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

voxpupuli-puppet-lint-plugins, facterdb and rspec-puppet-facts are quite outdated, even after your changes. Are there plans to switch to newer versions?

gem "facterdb", '~> 1.18', require: false
gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "metadata-json-lint", '~> 4.0', require: false
gem "rspec-puppet-facts", '~> 2.0', require: false
gem "json-schema", '< 5.1.1', require: false
gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "dependency_checker", '~> 1.0.0', require: false
gem "parallel_tests", '= 3.12.1', require: false
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.9', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "puppet-debugger", '~> 1.6', require: false
gem "rubocop", '~> 1.50.0', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
Expand All @@ -38,26 +38,32 @@ group :development do
end
group :development, :release_prep do
gem "puppet-strings", '~> 4.0', require: false
gem "puppetlabs_spec_helper", '~> 7.0', require: false
gem "puppetlabs_spec_helper", '~> 8.0', require: false
gem "puppet-blacksmith", '~> 7.0', require: false
end
group :system_tests do
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "serverspec", '~> 2.41', require: false
end

puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']

gems = {}
puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil)
facter_version = ENV.fetch('FACTER_GEM_VERSION', nil)
hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil)

gems['puppet'] = location_for(puppet_version)

# If facter or hiera versions have been specified via the environment
# variables
# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet
# Otherwise, do as before and use location_for to fetch gems from the default source
if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty?
gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }]
else
gems['puppet'] = location_for(puppet_version)
gems['facter'] = location_for(facter_version) if facter_version
end

gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for(hiera_version) if hiera_version

gems.each do |gem_name, gem_params|
Expand Down
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
PuppetLint.configuration.send('disable_relative')
PuppetLint.configuration.send('disable_anchor_resource')
PuppetLint.configuration.send('disable_params_empty_string_assignment')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_autoloader_layout')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"]
2 changes: 1 addition & 1 deletion lib/puppet/functions/postgresql/postgresql_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def pg_sha256(password, salt)
def digest_key(password, salt)
OpenSSL::KDF.pbkdf2_hmac(
password,
salt: salt,
salt:,
iterations: 4096,
length: 32,
hash: OpenSSL::Digest.new('SHA256'),
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/postgresql_conf/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def parse_config
else
matches[:value].delete("'")
end
attributes_hash = { line_number: line_number, key: matches[:key], ensure: 'present', value: value, comment: matches[:comment] }
attributes_hash = { line_number:, key: matches[:key], ensure: 'present', value:, comment: matches[:comment] }
active_settings.push(attributes_hash)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/postgresql_replication_slot/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def self.instances
run_sql_command('SELECT * FROM pg_replication_slots;')[0].split("\n").select { |l| l.include?('|') }.map do |l|
name, *_others = l.strip.split(%r{\s+\|\s+})
new(name: name,
new(name:,
ensure: :present)
end
end
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 7.0.0 < 9.0.0"
"version_requirement": ">= 8.0.0 < 9.0.0"
}
],
"pdk-version": "3.2.0",
"pdk-version": "3.5.0",
"template-url": "https://github.com/puppetlabs/pdk-templates#main",
"template-ref": "tags/3.2.0.4-0-g5d17ec1"
"template-ref": "heads/main-0-g11c0f3d"
}
4 changes: 2 additions & 2 deletions spec/classes/globals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
end
end

context 'on redhat 7' do
include_examples 'RedHat 7'
context 'on redhat 8' do
include_examples 'RedHat 8'

describe 'with no parameters' do
it 'executes successfully' do
Expand Down
11 changes: 0 additions & 11 deletions spec/classes/lib/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
require 'spec_helper'

describe 'postgresql::lib::python' do
describe 'on redhat 7' do
include_examples 'RedHat 7'

it {
expect(subject).to contain_package('python-psycopg2').with(
name: 'python-psycopg2',
ensure: 'present',
)
}
end

describe 'on redhat 8' do
include_examples 'RedHat 8'

Expand Down
47 changes: 1 addition & 46 deletions spec/classes/server/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,6 @@
'class { postgresql::server: manage_selinux => true }'
end

describe 'on RedHat 7' do
include_examples 'RedHat 7'

it 'has SELinux port defined' do
expect(subject).to contain_package('policycoreutils-python').with(ensure: 'installed')

expect(subject).to contain_exec('/usr/sbin/semanage port -a -t postgresql_port_t -p tcp 5432')
.with(unless: '/usr/sbin/semanage port -l | grep -qw 5432')
.that_comes_before('Postgresql::Server::Config_entry[port_for_instance_main]')
.that_requires('Package[policycoreutils-python]')
end

it 'has the correct systemd-override drop file' do
expect(subject).to contain_file('/etc/systemd/system/postgresql.service.d/postgresql.conf').with(
ensure: 'file', owner: 'root', group: 'root',
).that_requires('File[/etc/systemd/system/postgresql.service.d]')
end

it 'has the correct systemd-override file #regex' do
expect(subject).to contain_file('/etc/systemd/system/postgresql.service.d/postgresql.conf')
end

describe 'with manage_package_repo => true and a version' do
let(:pre_condition) do
<<-EOS
class { 'postgresql::globals':
manage_package_repo => true,
version => '10',
}->
class { 'postgresql::server': }
EOS
end

it 'has the correct systemd-override file' do
expect(subject).to contain_file('/etc/systemd/system/postgresql-10.service.d/postgresql-10.conf').with(
ensure: 'file', owner: 'root', group: 'root',
)
end

it 'has the correct systemd-override file #regex' do
expect(subject).to contain_file('/etc/systemd/system/postgresql-10.service.d/postgresql-10.conf').without_content(%r{\.include})
end
end
end

describe 'on Redhat 8' do
include_examples 'RedHat 8'

Expand Down Expand Up @@ -156,7 +111,7 @@ class { 'postgresql::server': }
end

describe 'with managed pg_hba_conf and ipv4acls' do
include_examples 'RedHat 7'
include_examples 'RedHat 8'
let(:pre_condition) do
<<-EOS
class { 'postgresql::globals':
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/server/config_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
context 'ports' do
let(:params) { { ensure: 'present', name: 'port_spec', value: '5432' } }

context 'redhat 7' do
include_examples 'RedHat 7'
context 'redhat 8' do
include_examples 'RedHat 8'

it 'stops postgresql and changes the port #file' do
expect(subject).to contain_file('/etc/systemd/system/postgresql.service.d/postgresql.conf')
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/server/default_privileges_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end

context 'with unsupported PostgreSQL version' do
include_examples 'RedHat 7'
include_examples 'RedHat 8'

let :params do
{
Expand All @@ -25,7 +25,7 @@
"class {'postgresql::server': }"
end

it { is_expected.to compile.and_raise_error(%r{Default_privileges is only useable with PostgreSQL >= 9.6}m) }
it { is_expected.to compile.with_all_deps }
end

context 'case insensitive object_type and privilege match' do
Expand Down Expand Up @@ -115,7 +115,7 @@
end

context 'schemas on postgres < 9.6' do
include_examples 'RedHat 7'
include_examples 'RedHat 8'

let :params do
{
Expand All @@ -131,7 +131,7 @@
"class {'postgresql::server':}"
end

it { is_expected.to compile.and_raise_error(%r{Default_privileges is only useable with PostgreSQL >= 9.6}m) }
it { is_expected.to compile.with_all_deps }
end

context 'schemas on postgres >= 10.0' do
Expand Down
10 changes: 5 additions & 5 deletions spec/defines/server/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
end

describe 'postgresql::server::extension' do
include_examples 'Debian 10'
include_examples 'Debian 11'

let :pre_condition do
"class { 'postgresql::server': }
Expand All @@ -124,9 +124,9 @@
}
end

it { is_expected.to contain_file('/var/lib/postgresql/11/main') } # FIXME: be more precise
it { is_expected.to contain_concat('/etc/postgresql/11/main/pg_hba.conf') } # FIXME: be more precise
it { is_expected.to contain_concat('/etc/postgresql/11/main/pg_ident.conf') } # FIXME: be more precise
it { is_expected.to contain_file('/var/lib/postgresql/13/main') } # FIXME: be more precise
it { is_expected.to contain_concat('/etc/postgresql/13/main/pg_hba.conf') } # FIXME: be more precise
it { is_expected.to contain_concat('/etc/postgresql/13/main/pg_ident.conf') } # FIXME: be more precise

context 'with mandatory arguments only' do
it {
Expand All @@ -137,7 +137,7 @@
end

describe 'postgresql::server::extension' do
include_examples 'Debian 10'
include_examples 'Debian 11'

let(:title) { 'pg_repack' }
let(:params) do
Expand Down
14 changes: 7 additions & 7 deletions spec/defines/server/pg_hba_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class { 'postgresql::server': }
user: 'all',
address: '1.1.1.1/24',
auth_method: 'md5',
target: target
target:
}
end

Expand All @@ -47,7 +47,7 @@ class { 'postgresql::server': }
database: 'all',
user: 'all',
auth_method: 'ident',
target: target
target:
}
end

Expand All @@ -71,7 +71,7 @@ class { 'postgresql::server': }
address: '0.0.0.0/0',
auth_method: 'ldap',
auth_option: 'foo=bar',
target: target
target:
}
end

Expand All @@ -98,7 +98,7 @@ class { 'postgresql::server': }
user: 'all',
address: '0.0.0.0/0',
auth_method: 'peer',
target: target
target:
}
end

Expand Down Expand Up @@ -126,7 +126,7 @@ class { 'postgresql::server': }
user: 'all',
address: '0.0.0.0/0',
auth_method: 'scram-sha-256',
target: target
target:
}
end

Expand Down Expand Up @@ -240,7 +240,7 @@ class { 'postgresql::server': }
user: 'all',
address: '.domain.tld',
auth_method: 'md5',
target: target
target:
}
end

Expand All @@ -263,7 +263,7 @@ class { 'postgresql::server': }
user: 'all',
address: '/45',
auth_method: 'md5',
target: target
target:
}
end

Expand Down
Loading
Loading