diff --git a/attributes/default.rb b/attributes/default.rb index a18b22b..1ed44f8 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,7 +1,7 @@ default['pacemaker']['nodes'] = ['node1', 'node2'] default['pacemaker']['primitive']['drbd']['agent'] = "ocf:linbit:drbd" -default['pacemaker']['primitive']['drbd']['params']['drbd_resource'] = "pair" +default['pacemaker']['primitive']['drbd']['params']['drbd_resource'] = "r0" default['pacemaker']['primitive']['drbd']['op']['monitor']['interval'] = "5s" default['pacemaker']['primitive']['drbd']['op']['monitor']['role'] = "Master" default['pacemaker']['primitive']['drbd']['active'] = ["node1", "node2"] @@ -14,7 +14,8 @@ default['pacemaker']['primitive']['cinder-volume']['active'] = ["node1", "node2" default['pacemaker']['primitive']['clvm']['agent'] = "ocf:lvm2:clvmd" default['pacemaker']['primitive']['clvm']['params']['daemon_timeout'] = "30" -default['pacemaker']['primitive']['clvm']['op']['monitor']['interval'] = "10s" +default['pacemaker']['primitive']['clvm']['op']['monitor']['interval'] = "5s" +default['pacemaker']['primitive']['clvm']['op']['monitor']['on-fail'] = "restart" default['pacemaker']['primitive']['clvm']['active'] = ["node1", "node2"] # Temporary attribute for vip resource. @@ -37,12 +38,12 @@ default['pacemaker']['primitive']['st-node2']['active'] = ["node1"] default['pacemaker']['location']['l-st-node1']['rsc_name'] = "st-node1" default['pacemaker']['location']['l-st-node1']['priority'] = "-inf" -default['pacemaker']['location']['l-st-node1']['node'] = "node1" +default['pacemaker']['location']['l-st-node1']['loc'] = "node1" default['pacemaker']['location']['l-st-node1']['active'] = ["node2"] default['pacemaker']['location']['l-st-node2']['rsc_name'] = "st-node2" default['pacemaker']['location']['l-st-node2']['priority'] = "-inf" -default['pacemaker']['location']['l-st-node2']['node'] = "node2" +default['pacemaker']['location']['l-st-node2']['loc'] = "node2" default['pacemaker']['location']['l-st-node2']['active'] = ["node1"] default['pacemaker']['ms']['drbd-cluster']['rsc_name'] = "drbd" diff --git a/providers/location.rb b/providers/location.rb index 67ea394..4b29a24 100644 --- a/providers/location.rb +++ b/providers/location.rb @@ -23,10 +23,10 @@ action :create do name = new_resource.name rsc = new_resource.rsc priority = new_resource.priority - node = new_resource.node + loc = new_resource.loc unless resource_exists?(name) - cmd = "crm configure location #{name} #{rsc} #{priority}: #{node}" + cmd = "crm configure location #{name} #{rsc} #{priority}: #{loc}" e = execute "configure location #{name}" do command cmd diff --git a/recipes/config.rb b/recipes/config.rb index eeda325..bddc3ab 100644 --- a/recipes/config.rb +++ b/recipes/config.rb @@ -42,17 +42,19 @@ node['pacemaker']['nodes'].each do |node| end end -node['pacemaker']['primitive'].each do |name, attr| - Chef::Log.debug "Pacemaker::primitive #{name}" - Chef::Log.debug "Attrs: #{attr}" +# Get cinder-volume's myip which might have been set by 'ktc-cinder' cookbook. +if node['pacemaker']['primitive'].include?('vip') and node['cinder']['services']['volume']['myip'] + node.default['pacemaker']['primitive']['vip']['params']['ip'] = node['cinder']['services']['volume']['myip'] +end +node['pacemaker']['primitive'].each do |name, attr| pacemaker_primitive name do agent attr['agent'] params attr['params'] meta attr['meta'] op attr['op'] action :create - only_if attr['active'].include?(node.name) + only_if { attr['active'].include?(node.name) } end end @@ -60,9 +62,9 @@ node['pacemaker']['location'].each do |name, attr| pacemaker_location name do rsc attr['rsc_name'] priority attr['priority'] - node attr['node'] + loc attr['loc'] action :create - only_if attr['active'].include?(node.name) + only_if { attr['active'].include?(node.name) } end end @@ -71,7 +73,7 @@ node['pacemaker']['ms'].each do |name, attr| rsc attr['rsc_name'] meta attr['meta'] action :create - only_if attr['active'].include?(node.name) + only_if { attr['active'].include?(node.name) } end end @@ -80,7 +82,7 @@ node['pacemaker']['clone'].each do |name, attr| rsc attr['rsc_name'] meta attr['meta'] action :create - only_if attr['active'].include?(node.name) + only_if { attr['active'].include?(node.name) } end end diff --git a/resources/location.rb b/resources/location.rb index db33d88..e6d46cc 100644 --- a/resources/location.rb +++ b/resources/location.rb @@ -24,4 +24,4 @@ default_action :create attribute :name, :kind_of => String, :name_attribute => true attribute :rsc, :kind_of => String attribute :priority, :kind_of => String -attribute :node, :kind_of => String +attribute :loc, :kind_of => String