From 01eab7262e67f71019e10096ccdddb9f3e8c573c Mon Sep 17 00:00:00 2001 From: Maqsood Ahmad Date: Tue, 7 Jul 2026 11:35:11 +0530 Subject: [PATCH] (MODULES-11858) Restore Puppet 7 support broken by 10.6.2 10.6.2 (PR #1646, "CAT-2385 Puppetcore update") bumped .rubocop.yml TargetRubyVersion to 3.1, so `rubocop -A` rewrote hash literals to Ruby 3.1 shorthand (`salt:` instead of `salt: salt`) in three custom functions/providers. That shorthand is a hard syntax error on Ruby < 3.1, and Puppet 7 ships Ruby 2.7 -- so any Puppet 7 catalog using postgresql::postgresql_password, postgresql_conf or postgresql_replication_slot failed to compile with "syntax error, unexpected ','" (issue #1685). Fix the Ruby side so existing Puppet 7 installations keep working: - .rubocop.yml: TargetRubyVersion back to '2.6' so autocorrect can't reintroduce the shorthand. - Revert the Ruby 3.1 shorthand hash syntax in the three lib files (keeping the unrelated postgresql_conf entry_regex bugfix from #1657). - Revert the same shorthand autocorrection in four spec files so they parse under the 2.6 target. Verified with `pdk validate`, the full unit suite (685 examples, 0 failures), and Litmus end-to-end applies on both Puppet 7.34/Ruby 2.7 and Puppet 8.10/Ruby 3.2 (install, idempotency, and a SCRAM-SHA-256 password hash stored in the live database). Fixes #1685 Co-Authored-By: Claude --- .rubocop.yml | 2 +- .../postgresql/postgresql_password.rb | 2 +- lib/puppet/provider/postgresql_conf/ruby.rb | 2 +- .../postgresql_replication_slot/ruby.rb | 2 +- spec/defines/server/pg_hba_rule_spec.rb | 14 +++++------ .../provider/postgresql_psql/ruby_spec.rb | 2 +- .../postgresql_replication_slot/ruby_spec.rb | 2 +- spec/unit/puppet/type/postgresql_psql_spec.rb | 24 +++++++++---------- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 47b1aadbe6..439ea84ee8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: 3.1 + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: diff --git a/lib/puppet/functions/postgresql/postgresql_password.rb b/lib/puppet/functions/postgresql/postgresql_password.rb index f34d412779..9ca4d81dbb 100644 --- a/lib/puppet/functions/postgresql/postgresql_password.rb +++ b/lib/puppet/functions/postgresql/postgresql_password.rb @@ -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'), diff --git a/lib/puppet/provider/postgresql_conf/ruby.rb b/lib/puppet/provider/postgresql_conf/ruby.rb index 59ba15d2a5..a5430e821a 100644 --- a/lib/puppet/provider/postgresql_conf/ruby.rb +++ b/lib/puppet/provider/postgresql_conf/ruby.rb @@ -29,7 +29,7 @@ def parse_config else matches[:value].delete("'") end - attributes_hash = { line_number:, key: matches[:key], ensure: 'present', value:, comment: matches[:comment] } + attributes_hash = { line_number: line_number, key: matches[:key], ensure: 'present', value: value, comment: matches[:comment] } active_settings.push(attributes_hash) end end diff --git a/lib/puppet/provider/postgresql_replication_slot/ruby.rb b/lib/puppet/provider/postgresql_replication_slot/ruby.rb index 257de341a3..31271cc51b 100644 --- a/lib/puppet/provider/postgresql_replication_slot/ruby.rb +++ b/lib/puppet/provider/postgresql_replication_slot/ruby.rb @@ -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:, + new(name: name, ensure: :present) end end diff --git a/spec/defines/server/pg_hba_rule_spec.rb b/spec/defines/server/pg_hba_rule_spec.rb index 302d2848e8..7d1187001c 100644 --- a/spec/defines/server/pg_hba_rule_spec.rb +++ b/spec/defines/server/pg_hba_rule_spec.rb @@ -25,7 +25,7 @@ class { 'postgresql::server': } user: 'all', address: '1.1.1.1/24', auth_method: 'md5', - target: + target: target } end @@ -47,7 +47,7 @@ class { 'postgresql::server': } database: 'all', user: 'all', auth_method: 'ident', - target: + target: target } end @@ -71,7 +71,7 @@ class { 'postgresql::server': } address: '0.0.0.0/0', auth_method: 'ldap', auth_option: 'foo=bar', - target: + target: target } end @@ -98,7 +98,7 @@ class { 'postgresql::server': } user: 'all', address: '0.0.0.0/0', auth_method: 'peer', - target: + target: target } end @@ -126,7 +126,7 @@ class { 'postgresql::server': } user: 'all', address: '0.0.0.0/0', auth_method: 'scram-sha-256', - target: + target: target } end @@ -240,7 +240,7 @@ class { 'postgresql::server': } user: 'all', address: '.domain.tld', auth_method: 'md5', - target: + target: target } end @@ -263,7 +263,7 @@ class { 'postgresql::server': } user: 'all', address: '/45', auth_method: 'md5', - target: + target: target } end diff --git a/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb b/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb index 5e3c705547..9f2c3b55e1 100644 --- a/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +++ b/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb @@ -5,7 +5,7 @@ describe Puppet::Type.type(:postgresql_psql).provider(:ruby) do let(:name) { 'rspec psql test' } let(:resource) do - Puppet::Type.type(:postgresql_psql).new({ name:, provider: :ruby }.merge(attributes)) + Puppet::Type.type(:postgresql_psql).new({ name: name, provider: :ruby }.merge(attributes)) end let(:provider) { resource.provider } diff --git a/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb b/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb index 676d783f18..032ceac752 100644 --- a/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb +++ b/spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb @@ -20,7 +20,7 @@ def success? let(:name) { 'standby' } let(:resource) do - type.new({ name:, provider: :ruby }.merge(attributes)) + type.new({ name: name, provider: :ruby }.merge(attributes)) end let(:sql_instances) do "abc | | physical | | | t | | | 0/3000420 diff --git a/spec/unit/puppet/type/postgresql_psql_spec.rb b/spec/unit/puppet/type/postgresql_psql_spec.rb index ed8a3b1b4a..871645534d 100644 --- a/spec/unit/puppet/type/postgresql_psql_spec.rb +++ b/spec/unit/puppet/type/postgresql_psql_spec.rb @@ -132,7 +132,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: } + { refreshonly: refreshonly } end context 'not refreshing' @@ -141,7 +141,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: } + { refreshonly: refreshonly } end context 'refreshing' @@ -152,7 +152,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: } + { refreshonly: refreshonly } end context 'not refreshing' @@ -161,7 +161,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly: } + { refreshonly: refreshonly } end context 'refreshing' @@ -176,7 +176,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'not refreshing' @@ -185,7 +185,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'refreshing' @@ -196,7 +196,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'not refreshing' @@ -205,7 +205,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'refreshing' @@ -220,7 +220,7 @@ [true, :true].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'not refreshing' @@ -229,7 +229,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'refreshing' @@ -240,7 +240,7 @@ [false, :false].each do |refreshonly| context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'not refreshing' @@ -249,7 +249,7 @@ context "refreshonly => #{refreshonly.inspect}" do let(:attributes) do - { refreshonly:, unless: 'SELECT something' } + { refreshonly: refreshonly, unless: 'SELECT something' } end context 'refreshing'