diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9a195e25..208124dc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-02-20 13:57:00 UTC using RuboCop version 1.50.2. +# on 2024-04-08 21:01:49 UTC using RuboCop version 1.60.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 @@ -15,6 +15,7 @@ Lint/DuplicateBranch: - 'spec/spec_helper_corosync.rb' # Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: @@ -51,10 +52,24 @@ RSpec/RepeatedExampleGroupBody: - 'spec/acceptance/corosync_class_spec.rb' # Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? Style/ClassEqualityComparison: Exclude: - 'lib/puppet/provider/cs_primitive/crm.rb' - 'lib/puppet/provider/cs_primitive/pcs.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'lib/puppet/provider/cs_group/crm.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantLineContinuation: + Exclude: + - 'spec/unit/puppet/type/cs_clone_spec.rb' diff --git a/lib/puppet/provider/cs_clone/pcs.rb b/lib/puppet/provider/cs_clone/pcs.rb index 814f5d21..1580d2a5 100644 --- a/lib/puppet/provider/cs_clone/pcs.rb +++ b/lib/puppet/provider/cs_clone/pcs.rb @@ -18,7 +18,7 @@ mk_resource_methods - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] def change_clone_id(type, primitive, id, cib) xpath = "/cib/configuration/resources/clone[descendant::#{type}[@id='#{primitive}']]" @@ -28,7 +28,7 @@ def change_clone_id(type, primitive, id, cib) return unless doc.root.attributes['id'] != id doc.root.attributes['id'] = id - cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chop] + cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chomp] self.class.run_command_in_cib(cmd, cib) end diff --git a/lib/puppet/provider/cs_colocation/pcs.rb b/lib/puppet/provider/cs_colocation/pcs.rb index 725c4012..b8bb7287 100644 --- a/lib/puppet/provider/cs_colocation/pcs.rb +++ b/lib/puppet/provider/cs_colocation/pcs.rb @@ -16,7 +16,7 @@ of current primitive colocations on the system; add, delete, or adjust various aspects.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] commands pcs: 'pcs' diff --git a/lib/puppet/provider/cs_commit/pcs.rb b/lib/puppet/provider/cs_commit/pcs.rb index 979e098c..f80bd4fe 100644 --- a/lib/puppet/provider/cs_commit/pcs.rb +++ b/lib/puppet/provider/cs_commit/pcs.rb @@ -15,6 +15,8 @@ abstract corosync/pacemaker vs. keepalived. This provider flushes the CIB generated by previous commands to cluster.' + defaultfor 'os.family' => %i[redhat debian] + commands cibadmin: 'cibadmin' # Required for block_until_ready commands pcs: 'pcs' diff --git a/lib/puppet/provider/cs_group/crm.rb b/lib/puppet/provider/cs_group/crm.rb index fa115700..22484cd6 100644 --- a/lib/puppet/provider/cs_group/crm.rb +++ b/lib/puppet/provider/cs_group/crm.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - begin require 'puppet_x/voxpupuli/corosync/provider/crmsh' rescue LoadError diff --git a/lib/puppet/provider/cs_group/pcs.rb b/lib/puppet/provider/cs_group/pcs.rb index 8e3a7702..caf34da7 100644 --- a/lib/puppet/provider/cs_group/pcs.rb +++ b/lib/puppet/provider/cs_group/pcs.rb @@ -13,7 +13,7 @@ Puppet::Type.type(:cs_group).provide(:pcs, parent: PuppetX::Voxpupuli::Corosync::Provider::Pcs) do desc 'Provider to add, delete, manipulate primitive groups.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] # Path to the pcs binary for interacting with the cluster configuration. commands pcs: '/usr/sbin/pcs' diff --git a/lib/puppet/provider/cs_location/pcs.rb b/lib/puppet/provider/cs_location/pcs.rb index 00650558..2defb0d7 100644 --- a/lib/puppet/provider/cs_location/pcs.rb +++ b/lib/puppet/provider/cs_location/pcs.rb @@ -16,7 +16,7 @@ of current primitive locations on the system; add, delete, or adjust various aspects.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] has_feature :discovery commands pcs: 'pcs' diff --git a/lib/puppet/provider/cs_order/pcs.rb b/lib/puppet/provider/cs_order/pcs.rb index a527910a..73dc81e3 100644 --- a/lib/puppet/provider/cs_order/pcs.rb +++ b/lib/puppet/provider/cs_order/pcs.rb @@ -16,7 +16,7 @@ of current primitive start orders on the system; add, delete, or adjust various aspects.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] has_feature :kindness diff --git a/lib/puppet/provider/cs_primitive/pcs.rb b/lib/puppet/provider/cs_primitive/pcs.rb index 7e27a1d5..be13ede2 100644 --- a/lib/puppet/provider/cs_primitive/pcs.rb +++ b/lib/puppet/provider/cs_primitive/pcs.rb @@ -23,7 +23,7 @@ mk_resource_methods - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] # given an XML element (a from cibadmin), produce a hash suitible # for creating a new provider instance. diff --git a/lib/puppet/provider/cs_property/pcs.rb b/lib/puppet/provider/cs_property/pcs.rb index 3132c2aa..6e1a5f54 100644 --- a/lib/puppet/provider/cs_property/pcs.rb +++ b/lib/puppet/provider/cs_property/pcs.rb @@ -15,7 +15,7 @@ abstract corosync/pacemaker vs. keepalived. This provider will check the state of Corosync cluster configuration properties.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] # Path to the pcs binary for interacting with the cluster configuration. commands pcs: 'pcs' diff --git a/lib/puppet/provider/cs_rsc_defaults/pcs.rb b/lib/puppet/provider/cs_rsc_defaults/pcs.rb index a730c3b4..e7065bd7 100644 --- a/lib/puppet/provider/cs_rsc_defaults/pcs.rb +++ b/lib/puppet/provider/cs_rsc_defaults/pcs.rb @@ -15,7 +15,7 @@ abstract corosync/pacemaker vs. keepalived. This provider will check the state of Corosync global defaults for resource options.' - defaultfor operatingsystem: %i[fedora centos redhat] + defaultfor 'os.family' => %i[redhat debian] # Path to the pcs binary for interacting with the cluster configuration. commands pcs: 'pcs' diff --git a/lib/puppet/provider/cs_shadow/pcs.rb b/lib/puppet/provider/cs_shadow/pcs.rb index d89d9ea1..64c6bc47 100644 --- a/lib/puppet/provider/cs_shadow/pcs.rb +++ b/lib/puppet/provider/cs_shadow/pcs.rb @@ -15,6 +15,8 @@ abstract corosync/pacemaker vs. keepalived. This provider initializes a new CIB to begin tracking cluster changes.' + defaultfor 'os.family' => %i[redhat debian] + commands cibadmin: 'cibadmin' # Required for block_until_ready commands pcs: 'pcs' diff --git a/spec/acceptance/cs_location_spec.rb b/spec/acceptance/cs_location_spec.rb index 80f4a7c8..4665e9e5 100755 --- a/spec/acceptance/cs_location_spec.rb +++ b/spec/acceptance/cs_location_spec.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true +# rubocop:disable Style/FrozenStringLiteralComment require 'spec_helper_acceptance' @@ -243,3 +243,5 @@ class { 'corosync': end end end + +# rubocop:enable Style/FrozenStringLiteralComment diff --git a/spec/acceptance/cs_order_spec.rb b/spec/acceptance/cs_order_spec.rb index f008f800..ad69242c 100644 --- a/spec/acceptance/cs_order_spec.rb +++ b/spec/acceptance/cs_order_spec.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true +# rubocop:disable Style/FrozenStringLiteralComment require 'spec_helper_acceptance' @@ -173,3 +173,5 @@ class { 'corosync': end end end + +# rubocop:enable Style/FrozenStringLiteralComment diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 00177b0d..afdd8adc 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -26,13 +26,13 @@ # On Debian-based, service state transitions (restart, stop) hang indefinitely and # lead to test timeouts if there is a service unit of Type=notify involved. # Use Type=simple as a workaround. See issue 455. - if host[:hypervisor] =~ %r{docker} && fact_on(host, 'os.family') == 'Debian' + if host[:hypervisor] =~ %r{(vagrant|docker)} && fact_on(host, 'os.family') == 'Debian' on host, 'mkdir /etc/systemd/system/corosync.service.d' on host, 'echo -e "[Service]\nType=simple" > /etc/systemd/system/corosync.service.d/10-type-simple.conf' end # Issue 455: On Centos-based there are recurring problems with the pacemaker systemd service # refusing to stop its crmd subprocess leading to test timeouts. Force a fast SigKill here. - if host[:hypervisor] =~ %r{docker} && fact_on(host, 'os.family') == 'RedHat' && fact_on(host, 'os.release.major') == '7' + if host[:hypervisor] =~ %r{(vagrant|docker)} && fact_on(host, 'os.family') == 'RedHat' && fact_on(host, 'os.release.major') == '7' on host, 'mkdir /etc/systemd/system/pacemaker.service.d' on host, 'echo -e "[Service]\nSendSIGKILL=yes\nTimeoutStopSec=60s" > /etc/systemd/system/pacemaker.service.d/10-timeout.conf' end diff --git a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb index f4782389..290c8f9e 100644 --- a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb +++ b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb @@ -245,7 +245,7 @@ def clone_xml(name) Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--query', '--xpath', xpath], failonfail: true, combine: true).at_least_once.returns( Puppet::Util::Execution::ProcessOutput.new(clone_xml('apache_service-clone'), 0) ) - Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chop], failonfail: true, combine: true).at_least_once.returns( + Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chomp], failonfail: true, combine: true).at_least_once.returns( Puppet::Util::Execution::ProcessOutput.new('', 0) ) instance.change_clone_id('primitive', 'apache_service', 'apache_service-newclone', nil)