From fe26701ca9e145d1f75ec2119398fac92170b4a0 Mon Sep 17 00:00:00 2001 From: Christoph Maser Date: Sun, 13 Oct 2024 19:48:25 +0200 Subject: [PATCH] set default providers to pcs for debian/ubuntu --- lib/puppet/provider/cs_clone/pcs.rb | 2 +- lib/puppet/provider/cs_colocation/pcs.rb | 2 +- lib/puppet/provider/cs_commit/pcs.rb | 2 ++ lib/puppet/provider/cs_group/pcs.rb | 2 +- lib/puppet/provider/cs_location/pcs.rb | 2 +- lib/puppet/provider/cs_order/pcs.rb | 2 +- lib/puppet/provider/cs_primitive/pcs.rb | 2 +- lib/puppet/provider/cs_property/pcs.rb | 2 +- lib/puppet/provider/cs_rsc_defaults/pcs.rb | 2 +- lib/puppet/provider/cs_shadow/pcs.rb | 2 ++ spec/acceptance/cs_commit_spec.rb | 12 ++++++------ spec/spec_helper_acceptance.rb | 4 ++-- 12 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/puppet/provider/cs_clone/pcs.rb b/lib/puppet/provider/cs_clone/pcs.rb index 81d153d0..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}']]" 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/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_commit_spec.rb b/spec/acceptance/cs_commit_spec.rb index 550735df..9b9aa974 100644 --- a/spec/acceptance/cs_commit_spec.rb +++ b/spec/acceptance/cs_commit_spec.rb @@ -72,7 +72,7 @@ class { 'corosync': primitives => [ 'apache2_vip', 'apache2_service' ], cib => 'puppet', notify => Cs_commit['puppet'] - } + } -> cs_commit { 'puppet': } @@ -102,7 +102,7 @@ class { 'corosync': end it 'creates the vip resource in the cib' do - command = if fact('default_provider') == 'pcs' && fact('os.name') != 'Ubuntu' + command = if fact('default_provider') == 'pcs' if Gem::Version.new(fact('pcs_version')) < Gem::Version.new('0.10.0') 'pcs resource show' else @@ -139,7 +139,7 @@ class { 'corosync': end it 'creates the vip resource in the shadow cib' do - command = if fact('default_provider') == 'pcs' && fact('os.name') != 'Ubuntu' + command = if fact('default_provider') == 'pcs' if Gem::Version.new(fact('pcs_version')) < Gem::Version.new('0.10.0') "pcs resource show -f #{pcs_shadow_cib}" else @@ -154,7 +154,7 @@ class { 'corosync': end it 'creates the service resource in the shadow cib' do - command = if fact('default_provider') == 'pcs' && fact('os.name') != 'Ubuntu' + command = if fact('default_provider') == 'pcs' if Gem::Version.new(fact('pcs_version')) < Gem::Version.new('0.10.0') "pcs resource show -f #{pcs_shadow_cib}" else @@ -169,7 +169,7 @@ class { 'corosync': end it 'creates the colocation in the shadow cib and apache2_vip is the "with" resource' do - command = if fact('default_provider') == 'pcs' && fact('os.name') != 'Ubuntu' + command = if fact('default_provider') == 'pcs' "pcs cluster cib -f #{pcs_shadow_cib} | grep apache2_vip_with_service" else 'CIB_shadow=puppet cibadmin --query | grep apache2_vip_with_service' @@ -180,7 +180,7 @@ class { 'corosync': end it 'creates the colocation in the shadow cib and apache2_service is the main resource' do - command = if fact('default_provider') == 'pcs' && fact('os.name') != 'Ubuntu' + command = if fact('default_provider') == 'pcs' "pcs cluster cib -f #{pcs_shadow_cib} | grep apache2_vip_with_service" else 'CIB_shadow=puppet cibadmin --query | grep apache2_vip_with_service' diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 1eae24b2..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{(vagrant|docker|container_other)} && 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{(vagrant|docker|container_other)} && 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