Make pcs resource config/show work depending on the installed pcs version
When we added Id8807a644a6d53f89f99b9db988cbbca99abb7ab we were under the impression that train and centos-7 was not a thing. Since centos-7 pcs does not have the pcs resource config it is likely we will fail to recognize existing resources. This can be removed once we stop supporting centos 7, but for now let's support both transparently. Tested on both centos-7 env where it was failing and on a centos-8 train deployment. Closes-Bug: #1915519 Change-Id: Ie07b37581e844b64063e5e501f09edf4c8ef24e3
This commit is contained in:
parent
2f4b6fafcb
commit
6e272bf9ec
|
@ -178,7 +178,7 @@ Puppet::Type.type(:pcmk_bundle).provide(:default) do
|
|||
end
|
||||
|
||||
def resource_exists?
|
||||
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
|
||||
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
|
||||
if ret == false then
|
||||
|
|
|
@ -37,6 +37,17 @@ def pcs_cli_version()
|
|||
return pcs_cli_version
|
||||
end
|
||||
|
||||
# returns 'show' or 'config' depending on the pcs version
|
||||
# In case pcs returns '' we choose the more recent 'config' default
|
||||
# (Although in that case it is likely it will fail differently anyways)
|
||||
def pcs_config_or_show()
|
||||
if Puppet::Util::Package.versioncmp(pcs_cli_version(), '0.10.0') < 0
|
||||
return 'show'
|
||||
else
|
||||
return 'config'
|
||||
end
|
||||
end
|
||||
|
||||
def crm_node_l()
|
||||
begin
|
||||
nodes = `#{CRMNODE_BIN} -l`
|
||||
|
@ -191,7 +202,7 @@ def pcs_create_with_verify(name, resource_name, cmd, tries=1, try_sleep=0)
|
|||
pcs_out = `#{PCS_BIN} #{cmd} 2>&1`
|
||||
if $?.exitstatus == 0
|
||||
sleep try_sleep
|
||||
cmd_show = "#{PCS_BIN} resource config " + resource_name
|
||||
cmd_show = "#{PCS_BIN} resource " + pcs_config_or_show() + " " + resource_name
|
||||
Puppet.debug("Verifying with: "+cmd_show)
|
||||
`#{cmd_show}`
|
||||
if $?.exitstatus == 0
|
||||
|
|
|
@ -81,7 +81,7 @@ Puppet::Type.type(:pcmk_remote).provide(:default) do
|
|||
end
|
||||
|
||||
def resource_exists?
|
||||
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
|
||||
@resource[:try_sleep], false, @resource[:post_success_sleep])
|
||||
if ret == false then
|
||||
|
|
|
@ -159,7 +159,7 @@ Puppet::Type.type(:pcmk_resource).provide(:default) do
|
|||
end
|
||||
|
||||
def resource_exists?
|
||||
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
|
||||
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
|
||||
if ret == false then
|
||||
|
|
|
@ -103,7 +103,7 @@ Puppet::Type.type(:pcmk_stonith).provide(:default) do
|
|||
end
|
||||
|
||||
def stonith_resource_exists?
|
||||
cmd = 'stonith config ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
cmd = 'stonith ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
|
||||
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
|
||||
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
|
||||
if ret == false then
|
||||
|
|
Loading…
Reference in New Issue