diff --git a/lib/puppet/provider/cs_clone/crm.rb b/lib/puppet/provider/cs_clone/crm.rb index 253f6a05..f95c5558 100644 --- a/lib/puppet/provider/cs_clone/crm.rb +++ b/lib/puppet/provider/cs_clone/crm.rb @@ -38,6 +38,9 @@ def self.instances globally_unique: items['globally-unique'], ordered: items['ordered'], interleave: items['interleave'], + promotable: items['promotable'], + promoted_max: items['promoted-max'], + promoted_node_max: items['promoted-node-max'], existing_resource: :true } @@ -67,6 +70,9 @@ def create ordered: @resource[:ordered], interleave: @resource[:interleave], cib: @resource[:cib], + promotable: @resource[:promotable], + promoted_max: @resource[:promoted_max], + promoted_node_max: @resource[:promoted_node_max], existing_resource: :false } end @@ -105,7 +111,10 @@ def flush notify_clones: 'notify', globally_unique: 'globally-unique', ordered: 'ordered', - interleave: 'interleave' + interleave: 'interleave', + promotable: 'promotable', + promoted_max: 'promoted-max', + promoted_node_max: 'promoted-node-max' }.each do |property, clone_property| meta << "#{clone_property}=#{@resource.should(property)}" unless @resource.should(property) == :absent end diff --git a/lib/puppet/provider/cs_clone/pcs.rb b/lib/puppet/provider/cs_clone/pcs.rb index d1a94b75..5192ccae 100644 --- a/lib/puppet/provider/cs_clone/pcs.rb +++ b/lib/puppet/provider/cs_clone/pcs.rb @@ -49,7 +49,10 @@ def self.instances notify_clones: items['notify'], globally_unique: items['globally-unique'], ordered: items['ordered'], - interleave: items['interleave'] + interleave: items['interleave'], + promotable: items['promotable'], + promoted_max: items['promoted-max'], + promoted_node_max: items['promoted-node-max'] } if e.elements['primitive'] @@ -82,7 +85,10 @@ def create notify_clones: @resource[:notify_clones], globally_unique: @resource[:globally_unique], ordered: @resource[:ordered], - interleave: @resource[:interleave] + interleave: @resource[:interleave], + promotable: @resource[:promotable], + promoted_max: @resource[:promoted_max], + promoted_node_max: @resource[:promoted_node_max] } end @@ -125,7 +131,10 @@ def flush notify_clones: 'notify', globally_unique: 'globally-unique', ordered: 'ordered', - interleave: 'interleave' + interleave: 'interleave', + promotable: 'promotable', + promoted_max: 'promoted-max', + promoted_node_max: 'promoted-node-max' }.each do |property, clone_property| cmd << "#{clone_property}=#{@resource.should(property)}" unless @resource.should(property) == :absent end diff --git a/lib/puppet/type/cs_clone.rb b/lib/puppet/type/cs_clone.rb index a8ff4125..06de7cdf 100644 --- a/lib/puppet/type/cs_clone.rb +++ b/lib/puppet/type/cs_clone.rb @@ -76,6 +76,31 @@ defaultto :absent end + newproperty(:promotable) do + desc 'If true, clone instances can perform a special role that Pacemaker will manage via the resource agent’s + promote and demote actions. The resource agent must support these actions. Allowed values: false, true' + + newvalues(:true, :false, :absent) + + defaultto :absent + end + + newproperty(:promoted_max) do + desc 'If promotable is true, the number of instances that can be promoted at one time across the entire cluster' + + newvalues(%r{\d+}, :absent) + + defaultto :absent + end + + newproperty(:promoted_node_max) do + desc 'If promotable is true and globally-unique is false, the number of clone instances can be promoted at one time on a single node' + + newvalues(%r{\d+}, :absent) + + defaultto :absent + end + newparam(:cib) do desc "Corosync applies its configuration immediately. Using a CIB allows you to group multiple primitives and relationships to be applied at diff --git a/spec/unit/puppet/provider/cs_clone_crm_spec.rb b/spec/unit/puppet/provider/cs_clone_crm_spec.rb index f206337c..a4cf3cf2 100644 --- a/spec/unit/puppet/provider/cs_clone_crm_spec.rb +++ b/spec/unit/puppet/provider/cs_clone_crm_spec.rb @@ -195,5 +195,23 @@ def expect_update(pattern) expect_update(%r{\sinterleave=true}) instance.flush end + + it 'sets promotable' do + instance.resource[:interleave] = :true + expect_update(%r{\spromotable=true}) + instance.flush + end + + it 'sets max promoted' do + instance.resource[:promoted_max] = 3 + expect_update(%r{\spromoted-max=3}) + instance.flush + end + + it 'sets max node promoted' do + instance.resource[:promoted_node_max] = 3 + expect_update(%r{\spromoted-node-max=3}) + instance.flush + end end end diff --git a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb index 42fc162b..4dae87a7 100644 --- a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb +++ b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb @@ -176,6 +176,24 @@ expect_commands(%r{interleave=true}) instance.flush end + + it 'sets promotable' do + instance.resource[:promotable] = :true + expect_commands(%r{promotable=true}) + instance.flush + end + + it 'sets max promoted' do + instance.resource[:promotable_max] = 3 + expect_commands(%r{promotable-max=3}) + instance.flush + end + + it 'sets max node promotable' do + instance.resource[:promotable_node_max] = 3 + expect_commands(%r{promotable-node-max=3}) + instance.flush + end end context 'when changing clone id' do diff --git a/spec/unit/puppet/type/cs_clone_spec.rb b/spec/unit/puppet/type/cs_clone_spec.rb index e98425f4..396744fb 100644 --- a/spec/unit/puppet/type/cs_clone_spec.rb +++ b/spec/unit/puppet/type/cs_clone_spec.rb @@ -27,8 +27,8 @@ end end - [:primitive, :clone_max, :clone_node_max, :notify_clones, :globally_unique, - :ordered, :interleave].each do |property| + [:primitive, :clone_max, :clone_node_max, :notify_clones, :globally_unique, :ordered, + :interleave, :promotable, :promoted_max, :promoted_node_max].each do |property| it "should have a #{property} property" do expect(subject).to be_validproperty(property) end @@ -40,7 +40,7 @@ end describe 'when validating attributes' do - [:notify_clones, :globally_unique, :ordered, :interleave].each do |attribute| + [:notify_clones, :globally_unique, :ordered, :interleave, :promotable].each do |attribute| it "should validate that the #{attribute} attribute can be true/false" do [true, false].each do |value| expect(subject.new(