Fix constraint::order when constraint_params is undef

constraint_params is an optional parameter which default to undef.
When it is not defined the creation of a pacemaker::constraint::order
resource will file with:

Error: /Stage[main]/Main/Pacemaker::Constraint::Order[control_vip-then-nova-evacuate]/Pcmk_constraint[order-ip-10.0.0.7-novaevacuate]/ensure:
  change from absent to present failed: Could not set 'present' on ensure:
    no implicit conversion of nil into String at /etc/puppet/modules/pacemaker/manifests/constraint/order.pp:77

The reason is that we add 'constraint_params' to a string even when it
is undefined (nil). Let's only add the string when it is non_empty:

/Stage[main]/Main/Pacemaker::Constraint::Order[control_vip-then-nova-evacuate]/Pcmk_constraint[order-ip-10.0.0.7-novaevacuate]/ensure: created

Change-Id: I680c7039dd47af894b87d45f7df81c589a0e6dfa
This commit is contained in:
Michele Baldessari 2017-09-29 19:46:55 +02:00
parent a4aa655a3f
commit 4a5e1df0c9
1 changed files with 5 additions and 1 deletions

View File

@ -22,7 +22,11 @@ Puppet::Type.type(:pcmk_constraint).provide(:default) do
when :order
first_resource = @resource[:first_resource].gsub(':', '.')
second_resource = @resource[:second_resource].gsub(':', '.')
cmd = 'constraint order ' + @resource[:first_action] + ' ' + first_resource + ' then ' + @resource[:second_action] + ' ' + second_resource + ' ' + @resource[:constraint_params]
constraint_params = @resource[:constraint_params]
cmd = 'constraint order ' + @resource[:first_action] + ' ' + first_resource + ' then ' + @resource[:second_action] + ' ' + second_resource
if not_empty_string(constraint_params)
cmd += ' ' + constraint_params
end
else
fail(String(@resource[:constraint_type]) + ' is an invalid location type')
end