Skip to content

Commit

Permalink
Merge 7af4a0e into fe3b8a8
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeluxe committed May 8, 2019
2 parents fe3b8a8 + 7af4a0e commit 33b6c04
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/facter/pacemakerd_version.rb
@@ -0,0 +1,10 @@
Facter.add(:pacemakerd_version) do
setcode do
pacemakerd_version_string = Facter::Util::Resolution.exec('pacemakerd --version 2>&1')

unless pacemakerd_version_string.nil?
match = %r{^Pacemaker (\d+.\d+(.\d+)?)}.match(pacemakerd_version_string)
match[1] unless match.nil?
end
end
end
8 changes: 8 additions & 0 deletions lib/puppet/provider/cs_location/crm.rb
Expand Up @@ -19,6 +19,14 @@

mk_resource_methods

# we need to check if we run at least pacemakerd version 1.1.13 before enabling feature discovery
# see http://blog.clusterlabs.org/blog/2014/feature-spotlight-controllable-resource-discovery
unless Facter.value('pacemakerd_version').nil?
if Puppet::Util::Package.versioncmp(Facter.value('pacemakerd_version'), '1.1.13') >= 0
has_feature :discovery
end
end

def self.instances
block_until_ready

Expand Down
8 changes: 4 additions & 4 deletions spec/acceptance/cs_location_spec.rb
Expand Up @@ -98,16 +98,16 @@ class { 'corosync':
end
end

if fact('osfamily') == 'RedHat'
it 'creates a location with resource-discovery=exclusive on EL-based systems' do
if Gem::Version.new(fact('pacemakerd_version')) >= Gem::Version.new('1.1.13')
it 'creates a location with resource-discovery=exclusive on pacemakerd version >= 1.1.13' do
shell('cibadmin --query | grep duncan_vip_there') do |r|
expect(r.stdout).to match(%r{resource-discovery="exclusive"})
end
end
end

if fact('osfamily') != 'RedHat'
it 'creates a location without resource-discovery=exclusive on non-RH systems' do
if Gem::Version.new(fact('pacemakerd_version')) < Gem::Version.new('1.1.13')
it 'creates a location without resource-discovery=exclusive on pacemakerd version < 1.1.13' do
shell('cibadmin --query | grep duncan_vip_there') do |r|
expect(r.stdout).not_to match(%r{resource-discovery="exclusive"})
end
Expand Down

0 comments on commit 33b6c04

Please sign in to comment.