stonith: Ease deployment with SBD
While we cannot fully deploy SBD fencing (the user needs to provide the devices and to make sure there's a watchdog for this hardware), we can help a bit by doing the last few bits.
This commit is contained in:
@@ -34,9 +34,14 @@ default[:pacemaker][:founder] = false
|
|||||||
default[:pacemaker][:crm][:initial_config_file] = "/etc/corosync/crm-initial.conf"
|
default[:pacemaker][:crm][:initial_config_file] = "/etc/corosync/crm-initial.conf"
|
||||||
default[:pacemaker][:crm][:no_quorum_policy] = "ignore"
|
default[:pacemaker][:crm][:no_quorum_policy] = "ignore"
|
||||||
|
|
||||||
# Values can be "disabled", "manual", "shared", "per_node"
|
# Values can be "disabled", "manual", "sbd", "shared", "per_node"
|
||||||
default[:pacemaker][:stonith][:mode] = "disabled"
|
default[:pacemaker][:stonith][:mode] = "disabled"
|
||||||
|
|
||||||
|
# This hash will contain devices for each node.
|
||||||
|
# For instance:
|
||||||
|
# default[:pacemaker][:stonith][:sbd][:nodes][$node][:devices] = ['/dev/disk/by-id/foo-part1', '/dev/disk/by-id/bar-part1']
|
||||||
|
default[:pacemaker][:stonith][:sbd][:nodes] = {}
|
||||||
|
|
||||||
default[:pacemaker][:stonith][:shared][:agent] = ""
|
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:
|
||||||
|
@@ -25,6 +25,57 @@ when "disabled"
|
|||||||
when "manual"
|
when "manual"
|
||||||
# nothing!
|
# nothing!
|
||||||
|
|
||||||
|
when "sbd"
|
||||||
|
require 'shellwords'
|
||||||
|
|
||||||
|
sbd_devices = nil
|
||||||
|
sbd_devices ||= (node[:pacemaker][:stonith][:sbd][:nodes][node[:fqdn]][:devices] rescue nil)
|
||||||
|
sbd_devices ||= (node[:pacemaker][:stonith][:sbd][:nodes][node[:hostname]][:devices] rescue nil)
|
||||||
|
raise "No SBD devices defined!" if sbd_devices.nil? || sbd_devices.empty?
|
||||||
|
|
||||||
|
sbd_cmd = "sbd"
|
||||||
|
sbd_devices.each do |sbd_device|
|
||||||
|
sbd_cmd += " -d #{Shellwords.shellescape(sbd_device)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "Check if watchdog is present" do
|
||||||
|
command "test -c /dev/watchdog"
|
||||||
|
end
|
||||||
|
|
||||||
|
execute "Check SBD validity" do
|
||||||
|
command "#{sbd_cmd} dump &> /dev/null"
|
||||||
|
end
|
||||||
|
|
||||||
|
if node.platform == 'suse'
|
||||||
|
# We will want to explicitly allocate a slot the first time we come here
|
||||||
|
# (hence the use of a notification to trigger this execute).
|
||||||
|
# According to the man page, it should not be required, but apparently,
|
||||||
|
# I've hit bugs where I had to do that. So better be safe.
|
||||||
|
execute "Allocate SBD slot" do
|
||||||
|
command "#{sbd_cmd} allocate #{node[:hostname]}"
|
||||||
|
not_if "#{sbd_cmd} list | grep -q \" #{node[:hostname]} \""
|
||||||
|
action :nothing
|
||||||
|
end
|
||||||
|
|
||||||
|
template "/etc/sysconfig/sbd" do
|
||||||
|
source "sysconfig_sbd.erb"
|
||||||
|
owner "root"
|
||||||
|
group "root"
|
||||||
|
mode 0644
|
||||||
|
variables(
|
||||||
|
:sbd_devices => sbd_devices
|
||||||
|
)
|
||||||
|
# We want to allocate slots before restarting corosync
|
||||||
|
notifies :run, "execute[Allocate SBD slot]", :immediately
|
||||||
|
notifies :restart, "service[#{node[:corosync][:platform][:service_name]}]", :immediately
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
pacemaker_primitive "stonith-sbd" do
|
||||||
|
agent "stonith:external/sbd"
|
||||||
|
action :create
|
||||||
|
end
|
||||||
|
|
||||||
when "shared"
|
when "shared"
|
||||||
agent = node[:pacemaker][:stonith][:shared][:agent]
|
agent = node[:pacemaker][:stonith][:shared][:agent]
|
||||||
params = node[:pacemaker][:stonith][:shared][:params]
|
params = node[:pacemaker][:stonith][:shared][:params]
|
||||||
|
3
templates/suse/sysconfig_sbd.erb
Normal file
3
templates/suse/sysconfig_sbd.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
SBD_DEVICE="<%= @sbd_devices.join("; ") %>"
|
||||||
|
# The next line enables the watchdog support:
|
||||||
|
SBD_OPTS="-W"
|
Reference in New Issue
Block a user