Make sure we test for Promoted when looking for constraints

pacemaker 2.1 returns 'Promoted' as opposed to 'Master' in its
with-rsc-role output. Let's test for both of them to keep compatibility
forwards and backwards. See: https://github.com/ClusterLabs/pacemaker/commit/c3b7b13ef
for example.

Tested this on Centos9 and fixed the issue with puppet not detecting
that a constraint was already there.

Change-Id: Ic215719e52ef1cc8a7a99bafe5d7393f583cc7b7
This commit is contained in:
Michele Baldessari 2021-09-03 11:38:02 +02:00
parent 744f3b78aa
commit 99ac026c6d
1 changed files with 3 additions and 1 deletions

View File

@ -66,7 +66,9 @@ Puppet::Type.type(:pcmk_constraint).provide(:default) do
resource_location = @resource[:location].gsub(':', '.')
resource_resource = @resource[:resource].gsub(':', '.')
if @resource[:master_slave]
return true if line.include? resource_resource + ' with ' + resource_location and line.include? "with-rsc-role:Master"
# pacemaker 2.1 started returning Promoted instead of Master
# so we need to cater to both
return true if line.include? resource_resource + ' with ' + resource_location and (line.include? "with-rsc-role:Master" or line.include? "with-rsc-role:Promoted")
else
return true if line.include? resource_resource + ' with ' + resource_location
end