Refer to "Fencing agent", not "STONITH plugin"
This is the recommendation from HA people.
This commit is contained in:
@@ -37,7 +37,7 @@ default[:pacemaker][:crm][:no_quorum_policy] = "ignore"
|
|||||||
# Values can be "disabled", "manual", "shared", "per_node"
|
# Values can be "disabled", "manual", "shared", "per_node"
|
||||||
default[:pacemaker][:stonith][:mode] = "disabled"
|
default[:pacemaker][:stonith][:mode] = "disabled"
|
||||||
|
|
||||||
default[:pacemaker][:stonith][:shared][:plugin] = ""
|
default[:pacemaker][:stonith][:shared][:agent] = ""
|
||||||
# This can be either a string (containing a list of parameters) or a hash.
|
# This can be either a string (containing a list of parameters) or a hash.
|
||||||
# For instance:
|
# For instance:
|
||||||
# default[:pacemaker][:stonith][:shared][:params] = 'hostname="foo" password="bar"'
|
# default[:pacemaker][:stonith][:shared][:params] = 'hostname="foo" password="bar"'
|
||||||
@@ -45,7 +45,7 @@ default[:pacemaker][:stonith][:shared][:plugin] = ""
|
|||||||
# default[:pacemaker][:stonith][:shared][:params] = {"hostname" => "foo", "password" => "bar"}
|
# default[:pacemaker][:stonith][:shared][:params] = {"hostname" => "foo", "password" => "bar"}
|
||||||
default[:pacemaker][:stonith][:shared][:params] = {}
|
default[:pacemaker][:stonith][:shared][:params] = {}
|
||||||
|
|
||||||
default[:pacemaker][:stonith][:per_node][:plugin] = ""
|
default[:pacemaker][:stonith][:per_node][:agent] = ""
|
||||||
# This can be "all" or "self":
|
# This can be "all" or "self":
|
||||||
# - if set to "all", then every node will configure the stonith resources for
|
# - if set to "all", then every node will configure the stonith resources for
|
||||||
# all nodes in the cluster
|
# all nodes in the cluster
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
module PacemakerStonithHelper
|
module PacemakerStonithHelper
|
||||||
@@stonith_plugins = nil
|
@@stonith_agents = nil
|
||||||
|
|
||||||
def self.stonith_plugin_valid?(plugin)
|
def self.stonith_agent_valid?(agent)
|
||||||
if plugin.nil? || plugin.empty?
|
if agent.nil? || agent.empty?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
if @@stonith_plugins.nil?
|
if @@stonith_agents.nil?
|
||||||
out = %x{stonith -L}
|
out = %x{stonith -L}
|
||||||
if $?.success?
|
if $?.success?
|
||||||
@@stonith_plugins = out.split("\n")
|
@@stonith_agents = out.split("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
!@@stonith_plugins.nil? && @@stonith_plugins.include?(plugin)
|
!@@stonith_agents.nil? && @@stonith_agents.include?(agent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.assert_stonith_plugin_valid(plugin)
|
def self.assert_stonith_agent_valid(agent)
|
||||||
unless stonith_plugin_valid? plugin
|
unless stonith_agent_valid? agent
|
||||||
raise "STONITH plugin #{plugin} is not available!"
|
raise "STONITH fencing agent #{agent} is not available!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
# FIXME: delete old resources when switching mode (or plugin!)
|
# FIXME: delete old resources when switching mode (or agent!)
|
||||||
|
|
||||||
case node[:pacemaker][:stonith][:mode]
|
case node[:pacemaker][:stonith][:mode]
|
||||||
when "disabled"
|
when "disabled"
|
||||||
@@ -26,14 +26,14 @@ when "manual"
|
|||||||
# nothing!
|
# nothing!
|
||||||
|
|
||||||
when "shared"
|
when "shared"
|
||||||
plugin = node[:pacemaker][:stonith][:shared][:plugin]
|
agent = node[:pacemaker][:stonith][:shared][:agent]
|
||||||
params = node[:pacemaker][:stonith][:shared][:params]
|
params = node[:pacemaker][:stonith][:shared][:params]
|
||||||
|
|
||||||
# This needs to be done in the second phase of chef, because we need
|
# This needs to be done in the second phase of chef, because we need
|
||||||
# cluster-glue to be installed first; hence ruby_block
|
# cluster-glue to be installed first; hence ruby_block
|
||||||
ruby_block "Check if STONITH #{plugin} is available" do
|
ruby_block "Check if STONITH fencing agent #{agent} is available" do
|
||||||
block do
|
block do
|
||||||
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
|
PacemakerStonithHelper.assert_stonith_agent_valid agent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,31 +42,31 @@ when "shared"
|
|||||||
elsif params.is_a?(String)
|
elsif params.is_a?(String)
|
||||||
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
|
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
|
||||||
else
|
else
|
||||||
message = "Unknown format for STONITH shared parameters: #{params.inspect}."
|
message = "Unknown format for shared fencing agent parameters: #{params.inspect}."
|
||||||
Chef::Log.fatal(message)
|
Chef::Log.fatal(message)
|
||||||
raise message
|
raise message
|
||||||
end
|
end
|
||||||
|
|
||||||
unless primitive_params.has_key?("hostlist")
|
unless primitive_params.has_key?("hostlist")
|
||||||
message = "Missing hostlist parameter for STONITH shared!"
|
message = "Missing hostlist parameter for shared fencing agent!"
|
||||||
Chef::Log.fatal(message)
|
Chef::Log.fatal(message)
|
||||||
raise message
|
raise message
|
||||||
end
|
end
|
||||||
|
|
||||||
pacemaker_primitive "fencing" do
|
pacemaker_primitive "fencing" do
|
||||||
agent "stonith:#{plugin}"
|
agent "stonith:#{agent}"
|
||||||
params primitive_params
|
params primitive_params
|
||||||
action :create
|
action :create
|
||||||
end
|
end
|
||||||
|
|
||||||
when "per_node"
|
when "per_node"
|
||||||
plugin = node[:pacemaker][:stonith][:per_node][:plugin]
|
agent = node[:pacemaker][:stonith][:per_node][:agent]
|
||||||
|
|
||||||
# This needs to be done in the second phase of chef, because we need
|
# This needs to be done in the second phase of chef, because we need
|
||||||
# cluster-glue to be installed first; hence ruby_block
|
# cluster-glue to be installed first; hence ruby_block
|
||||||
ruby_block "Check if STONITH #{plugin} is available" do
|
ruby_block "Check if STONITH fencing agent #{agent} is available" do
|
||||||
block do
|
block do
|
||||||
PacemakerStonithHelper.assert_stonith_plugin_valid plugin
|
PacemakerStonithHelper.assert_stonith_agent_valid agent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,20 +83,20 @@ when "per_node"
|
|||||||
elsif params.is_a?(String)
|
elsif params.is_a?(String)
|
||||||
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
|
primitive_params = ::Pacemaker::Resource.extract_hash("params #{params}", "params")
|
||||||
else
|
else
|
||||||
message = "Unknown format for STONITH per-node parameters of #{node_name}: #{params.inspect}."
|
message = "Unknown format for per-node fencing agent parameters of #{node_name}: #{params.inspect}."
|
||||||
Chef::Log.fatal(message)
|
Chef::Log.fatal(message)
|
||||||
raise message
|
raise message
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only set one of hostname / hostlist param if none of them are present; we
|
# Only set one of hostname / hostlist param if none of them are present; we
|
||||||
# do not overwrite it as the user might have passed more information than
|
# do not overwrite it as the user might have passed more information than
|
||||||
# just the hostname (some plugins accept hostname:data in hostlist)
|
# just the hostname (some agents accept hostname:data in hostlist)
|
||||||
unless primitive_params.has_key?("hostname") || primitive_params.has_key?("hostlist")
|
unless primitive_params.has_key?("hostname") || primitive_params.has_key?("hostlist")
|
||||||
primitive_params["hostname"] = node_name
|
primitive_params["hostname"] = node_name
|
||||||
end
|
end
|
||||||
|
|
||||||
pacemaker_primitive stonith_resource do
|
pacemaker_primitive stonith_resource do
|
||||||
agent "stonith:#{plugin}"
|
agent "stonith:#{agent}"
|
||||||
params primitive_params
|
params primitive_params
|
||||||
action :create
|
action :create
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user