diff --git a/attributes/default.rb b/attributes/default.rb index 65c71d1..823937f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,6 +1,15 @@ # Only use short hostname (not FQDN) default['pacemaker']['nodes'] = ['node1', 'node2'] +# Stonith resources should be configured first! +default['pacemaker']['primitive']['st-node1']['agent'] = "stonith:null" +default['pacemaker']['primitive']['st-node1']['params']['hostlist'] = "#{pacemaker['nodes'][0]}" +default['pacemaker']['primitive']['st-node1']['active'] = ["#{pacemaker['nodes'][1]}"] + +default['pacemaker']['primitive']['st-node2']['agent'] = "stonith:null" +default['pacemaker']['primitive']['st-node2']['params']['hostlist'] = "#{pacemaker['nodes'][1]}" +default['pacemaker']['primitive']['st-node2']['active'] = ["#{pacemaker['nodes'][0]}"] + default['pacemaker']['primitive']['drbd']['agent'] = "ocf:linbit:drbd" default['pacemaker']['primitive']['drbd']['params']['drbd_resource'] = "r0" default['pacemaker']['primitive']['drbd']['op']['monitor']['interval'] = "5s" @@ -28,14 +37,6 @@ default['pacemaker']['primitive']['vip']['op']['monitor']['nic'] = "eth0" default['pacemaker']['primitive']['vip']['meta']['target-role'] = "Started" default['pacemaker']['primitive']['vip']['active'] = "#{pacemaker['nodes']}" -default['pacemaker']['primitive']['st-node1']['agent'] = "stonith:null" -default['pacemaker']['primitive']['st-node1']['params']['hostlist'] = "#{pacemaker['nodes'][0]}" -default['pacemaker']['primitive']['st-node1']['active'] = ["#{pacemaker['nodes'][1]}"] - -default['pacemaker']['primitive']['st-node2']['agent'] = "stonith:null" -default['pacemaker']['primitive']['st-node2']['params']['hostlist'] = "#{pacemaker['nodes'][1]}" -default['pacemaker']['primitive']['st-node2']['active'] = ["#{pacemaker['nodes'][0]}"] - default['pacemaker']['location']['l-st-node1']['rsc_name'] = "st-node1" default['pacemaker']['location']['l-st-node1']['priority'] = "-inf" default['pacemaker']['location']['l-st-node1']['loc'] = "#{pacemaker['nodes'][0]}" diff --git a/recipes/config.rb b/recipes/config.rb index 1e98118..29e0cdb 100644 --- a/recipes/config.rb +++ b/recipes/config.rb @@ -18,7 +18,7 @@ # limitations under the License. # -include_recipe "pacemaker::default" +include_recipe "pacemaker::setup" directory "/usr/lib/ocf/resource.d/openstack" do owner "root" diff --git a/recipes/default.rb b/recipes/default.rb index b78d527..2e1ae79 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -18,10 +18,4 @@ # limitations under the License. # -package "pacemaker" do - action :install -end - -service "pacemaker" do - action [:enable, :start] -end +include_recipe "pacemaker::config" diff --git a/recipes/setup.rb b/recipes/setup.rb new file mode 100644 index 0000000..4240022 --- /dev/null +++ b/recipes/setup.rb @@ -0,0 +1,31 @@ +# +# Author:: Robert Choi +# Cookbook Name:: pacemaker +# Recipe:: setup +# +# Copyright 2013, Robert Choi +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package "pacemaker" do + action :install + notifies :restart, "service[corosync]", :immediately +end + +execute "sleep 2" + +service "pacemaker" do + action [ :enable, :start ] + notifies :restart, "service[clvm]", :immediately +end