Skip to content
Prev Previous commit
Next Next commit
rubocop: autofix
  • Loading branch information
bastelfreak committed Sep 18, 2025
commit f065b844f61edac113f0574ab357afcd41603366
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
inherit_from: .rubocop_todo.yml

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

Expand Down
74 changes: 74 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
# using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'spec/defines/database/postgresql_ssl_rules_spec.rb'

# Offense count: 1
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
- 'spec/unit/util/puppetdb_validator_spec.rb'

# Offense count: 2
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'spec/acceptance/standalone_spec.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/functions/create_subsetting_resource_hash_spec.rb'
- 'spec/functions/flatten_java_args_spec.rb'

# Offense count: 4
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 9
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 8

# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
- 'spec/acceptance/standalone_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/unit/classes/master/config_spec.rb'

# Offense count: 1
RSpec/StubbedMock:
Exclude:
- 'spec/unit/facter/puppetdb_version_spec.rb'

# Offense count: 28
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 1
Style/MixinUsage:
Exclude:
- 'spec/spec_helper_local.rb'
4 changes: 1 addition & 3 deletions lib/puppet/provider/puppetdb_conn_validator/puppet_https.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def exists?
success = validator.attempt_connection
end

unless success
Puppet.notice("Failed to connect to puppetdb within timeout window of #{timeout} seconds; giving up.")
end
Puppet.notice("Failed to connect to puppetdb within timeout window of #{timeout} seconds; giving up.") unless success

success
end
Expand Down
6 changes: 1 addition & 5 deletions lib/puppet/util/puppetdb_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

# Validator class, for testing that PuppetDB is alive
class Puppet::Util::PuppetdbValidator
attr_reader :puppetdb_server
attr_reader :puppetdb_port
attr_reader :use_ssl
attr_reader :test_path
attr_reader :test_headers
attr_reader :puppetdb_server, :puppetdb_port, :use_ssl, :test_path, :test_headers

def initialize(puppetdb_server, puppetdb_port, use_ssl = true, test_path = '/pdb/meta/v1/version')
@puppetdb_server = puppetdb_server
Expand Down
15 changes: 7 additions & 8 deletions spec/acceptance/standalone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
require 'spec_helper_acceptance'

describe 'standalone' do
it_behaves_like 'puppetserver'

let(:puppetdb_params) {}
let(:manage_firewall) { "(getvar('facts.os.family') == 'RedHat' and Integer(getvar('facts.os.release.major')) > 7)" }
let(:postgres_version) { 'undef' } # default
let(:puppetdb_master_config_params) {}
let(:puppetdb_params) {}

let(:postgres_version) { 'undef' } # default
let(:manage_firewall) { "(getvar('facts.os.family') == 'RedHat' and Integer(getvar('facts.os.release.major')) > 7)" }
it_behaves_like 'puppetserver'

describe 'with defaults' do
it_behaves_like 'puppetdb'
Expand Down Expand Up @@ -48,9 +47,9 @@
end

context 'with manage report processor', :change do
['remove', 'add'].each do |outcome|
%w[remove add].each do |outcome|
context "#{outcome}s puppet config puppetdb report processor" do
let(:enable_reports) { (outcome == 'add') ? true : false }
let(:enable_reports) { outcome == 'add' }

let(:puppetdb_master_config_params) do
<<~EOS
Expand Down Expand Up @@ -96,7 +95,7 @@
~> service { 'puppetdb':
ensure => 'running',
}
EOS
EOS

apply_manifest(pp, expect_failures: false, debug: ENV.key?('DEBUG'))
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/database/default_read_grant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
database_read_only_username: 'puppetdb-read',
}
valid = {
'standard': defaults,
standard: defaults,
'standard with port': defaults.merge({ database_port: 5433 }),
}

Expand Down
4 changes: 2 additions & 2 deletions spec/defines/database/postgresql_ssl_rules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
postgres_version: '11',
puppetdb_server: 'localhost',
},
'monitor': {
monitor: {
database_name: 'opensesame',
database_username: 'grover',
postgres_version: '11',
Expand All @@ -24,7 +24,7 @@
postgres_version: '12',
puppetdb_server: 'localhost',
},
'monitor': {
monitor: {
database_name: 'opensesame',
database_username: 'grover',
postgres_version: '12',
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/database/read_only_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

valid = {
'puppetdb-read': defaults.merge({ password_hash: 'blash' }),
'spectest': {
spectest: {
read_database_username: 'spectest-read',
database_name: 'spectest',
database_owner: 'spectest',
Expand Down
5 changes: 3 additions & 2 deletions spec/functions/create_subsetting_resource_hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
it { is_expected.to run.with_params('test' => 1).and_raise_error(ArgumentError) }
it { is_expected.to run.with_params('foo', 'bar').and_raise_error(ArgumentError) }
it { is_expected.to run.with_params({ 'foo' => 1 }, { 'bar' => 2 }, 'baz' => 3).and_raise_error(ArgumentError) }

it {
is_expected.to run.with_params({ 'foo' => 1, 'bar' => 2 }, 'baz' => 3)
.and_return("'foo'" => { 'subsetting' => 'foo', 'value' => 1, 'baz' => 3 }, "'bar'" => { 'subsetting' => 'bar', 'value' => 2, 'baz' => 3 })
is_expected.to run.with_params({ 'foo' => 1, 'bar' => 2 }, 'baz' => 3).
and_return("'foo'" => { 'subsetting' => 'foo', 'value' => 1, 'baz' => 3 }, "'bar'" => { 'subsetting' => 'bar', 'value' => 2, 'baz' => 3 })
}
end
66 changes: 33 additions & 33 deletions spec/support/acceptance/shared/puppetdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@
shared_examples 'puppetdb' do
let(:pp) do
<<~PP
if $facts['os']['family'] == 'RedHat' {
# Work-around EL systemd in docker bug affecting forked services
file_line { 'puppetdb-unit-remove-pidfile':
path => '/lib/systemd/system/puppetdb.service',
line => '#PIDFile=/run/puppetlabs/puppetdb/puppetdb.pid',
match => '^PIDFile.*',
append_on_no_match => false,
require => Package['puppetdb'],
notify => Service['puppetdb'],
if $facts['os']['family'] == 'RedHat' {
# Work-around EL systemd in docker bug affecting forked services
file_line { 'puppetdb-unit-remove-pidfile':
path => '/lib/systemd/system/puppetdb.service',
line => '#PIDFile=/run/puppetlabs/puppetdb/puppetdb.pid',
match => '^PIDFile.*',
append_on_no_match => false,
require => Package['puppetdb'],
notify => Service['puppetdb'],
}
}
}

# reduce pgs memory
postgresql::server::config_entry { 'max_connections': value => '20' }
postgresql::server::config_entry { 'shared_buffers': value => '128kB' }
postgresql::server::config_entry { 'effective_cache_size': value => '24MB' }
postgresql::server::config_entry { 'maintenance_work_mem': value => '1MB' }
postgresql::server::config_entry { 'checkpoint_completion_target': value => '0.9' }
postgresql::server::config_entry { 'wal_buffers': value => '32kB' }
postgresql::server::config_entry { 'random_page_cost': value => '4' }
postgresql::server::config_entry { 'effective_io_concurrency': value => '2' }
postgresql::server::config_entry { 'work_mem': value => '204kB' }
postgresql::server::config_entry { 'huge_pages': value => 'off' }
postgresql::server::config_entry { 'min_wal_size': value => '80MB' }
postgresql::server::config_entry { 'max_wal_size': value => '1GB' }
# reduce pgs memory
postgresql::server::config_entry { 'max_connections': value => '20' }
postgresql::server::config_entry { 'shared_buffers': value => '128kB' }
postgresql::server::config_entry { 'effective_cache_size': value => '24MB' }
postgresql::server::config_entry { 'maintenance_work_mem': value => '1MB' }
postgresql::server::config_entry { 'checkpoint_completion_target': value => '0.9' }
postgresql::server::config_entry { 'wal_buffers': value => '32kB' }
postgresql::server::config_entry { 'random_page_cost': value => '4' }
postgresql::server::config_entry { 'effective_io_concurrency': value => '2' }
postgresql::server::config_entry { 'work_mem': value => '204kB' }
postgresql::server::config_entry { 'huge_pages': value => 'off' }
postgresql::server::config_entry { 'min_wal_size': value => '80MB' }
postgresql::server::config_entry { 'max_wal_size': value => '1GB' }

class { 'puppetdb':
postgres_version => #{postgres_version},
manage_firewall => #{manage_firewall},
database_max_pool_size => '2',
read_database_max_pool_size => '2',
#{puppetdb_params}
}
-> class { 'puppetdb::master::config':
#{puppetdb_master_config_params}
}
class { 'puppetdb':
postgres_version => #{postgres_version},
manage_firewall => #{manage_firewall},
database_max_pool_size => '2',
read_database_max_pool_size => '2',
#{puppetdb_params}
}
-> class { 'puppetdb::master::config':
#{puppetdb_master_config_params}
}
PP
end

Expand Down
8 changes: 4 additions & 4 deletions spec/support/unit/facts.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Rough conversion of grepping in the puppet source:
# grep defaultfor lib/puppet/provider/service/*.rb
# Source https://github.com/voxpupuli/voxpupuli-test/blob/master/lib/voxpupuli/test/facts.rb
add_custom_fact :service_provider, ->(_os, facts) do
add_custom_fact :service_provider, lambda { |_os, facts|
os = RSpec.configuration.facterdb_string_keys ? facts['os'] : facts[:os]
case os['family'].downcase
when 'archlinux'
Expand All @@ -17,12 +17,12 @@
when 'openbsd'
'openbsd'
when 'redhat'
(os['release']['major'].to_i >= 7) ? 'systemd' : 'redhat'
os['release']['major'].to_i >= 7 ? 'systemd' : 'redhat'
when 'suse'
(os['release']['major'].to_i >= 12) ? 'systemd' : 'redhat'
os['release']['major'].to_i >= 12 ? 'systemd' : 'redhat'
when 'windows'
'windows'
else
'init'
end
end
}
Loading