From 55d1d0a067c3e46dc2f29d48d2893f1ce4499cdd Mon Sep 17 00:00:00 2001 From: Tobias Wolter Date: Wed, 30 Dec 2020 16:34:01 +0100 Subject: [PATCH] Try to differentiate for version in pacemaker provider --- lib/puppet/provider/cs_primitive/pcs.rb | 6 +++++- lib/puppet_x/voxpupuli/corosync/provider/pcs.rb | 5 +++++ spec/spec_helper_acceptance.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/cs_primitive/pcs.rb b/lib/puppet/provider/cs_primitive/pcs.rb index 0c4781d2..0dbe5fe1 100644 --- a/lib/puppet/provider/cs_primitive/pcs.rb +++ b/lib/puppet/provider/cs_primitive/pcs.rb @@ -239,7 +239,11 @@ def _flush_resource(operations, parameters, utilization, metadatas) # if we are using a multistate/promotable resource, prepend ms_ before its name # and declare it as a multistate/promotable resource if @property_hash[:promotable] == :true - cmd = [command(:pcs), pcs_subcommand, 'promotable', "ms_#{@property_hash[:name]}", (@property_hash[:name]).to_s] + if Gem::Version.new(self.version) < Gem::Version.new('0.10.0') + cmd = [command(:pcs), pcs_subcommand, 'promotable', (@property_hash[:name]).to_s] + else + cmd = [command(:pcs), pcs_subcommand, 'master', "ms_#{@property_hash[:name]}", (@property_hash[:name]).to_s] + end unless @property_hash[:ms_metadata].empty? cmd << 'meta' @property_hash[:ms_metadata].each_pair do |k, v| diff --git a/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb b/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb index d33235ff..cb8ddfc4 100644 --- a/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb +++ b/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb @@ -99,4 +99,9 @@ def exists? debug(@property_hash.inspect) !(@property_hash[:ensure] == :absent || @property_hash.empty?) end + + def self.version + cmd = [command(:pcs), '--version'] + Puppet::Util::Execution.execute(cmd, { failonfail: failonfail }) + end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a65b7053..12823e77 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -39,7 +39,7 @@ pcs_version = 'undef' end on host, "echo default_provider=#{default_provider} > /opt/puppetlabs/facter/facts.d/pacemaker-provider.txt" - on host, "echo pcs_version=#{pcs_version} > /opt/puppetlabs/facter/facts.d/pacemaker-provider.txt" + on host, "echo pcs_version=#{pcs_version} >> /opt/puppetlabs/facter/facts.d/pacemaker-provider.txt" # 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.