Skip to content

Commit

Permalink
Try to differentiate for version in pacemaker provider
Browse files Browse the repository at this point in the history
  • Loading branch information
towo committed Dec 30, 2020
1 parent 740be9d commit 55d1d0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/puppet/provider/cs_primitive/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet_x/voxpupuli/corosync/provider/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 55d1d0a

Please sign in to comment.