public
Last active

Chef recipe for heartbeat

  • Download Gist
attributes/heartbeat.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# Cookbook Name:: heartbeat
# Attributes:: heartbeat
#
# Copyright 2008, Wikia, Inc.
#
# 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.
#
 
heartbeat Mash.new unless attribute?("heartbeat")
metadata.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
maintainer "Wikia, Inc."
maintainer_email "ops-l@wikia.com"
license "Apache 2.0"
description "Sets up a heartbeat cluster"
version "0.7"
 
%w{ ubuntu debian }.each do |os|
supports os
end
 
attribute "heartbeat",
:display_name => "Heartbeat Hash",
:description => "Hash of heartbeat attributes",
:type => "hash"
 
attribute "heartbeat/haresources",
:display_name => "Heartbeat resources",
:description => "The resources line for the cluster",
:default => ''
 
attribute "heartbeat/port",
:display_name => "Heartbeat port",
:description => "The heartbeat port",
:default => "694"
 
attribute "heartbeat/other_member",
:display_name => "Heartbeat cluster member",
:description => "The other member of the heartbeat cluster",
:default => ''
 
attribute "heartbeat/interface",
:display_name => "Heartbeat interface",
:description => "Interface that heartbeat listens on",
:default => "eth0"
 
attribute "heartbeat/nodes",
:display_name => "Heartbeat nodes",
:description => "Members of the heartbeat cluster",
:type => "array"
 
attribute "heartbeat/secret",
:display_name => "Heartbeat secret",
:description => "Shared cluster password",
:default => "changeme"
node_attributes
1 2 3 4 5 6 7 8 9 10 11
"heartbeat": {
"other_member": "192.168.0.5",
"port": "694",
"interface": "eth0",
"haresources": "lvs5 192.168.0.1/24 192.168.0.2/24",
"nodes": [
"node1",
"node2"
],
"secret": "XXXXX"
},
recipes/default.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#
# Cookbook Name:: heartbeat
# Recipe:: default
#
# Copyright 2009, Wikia Inc
#
# 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 "heartbeat"
 
template "/etc/ha.d/ha.cf" do
mode 0644
source "ha.cf.erb"
end
 
template "/etc/ha.d/authkeys" do
mode 0600
source "authkeys.erb"
end
 
template "/etc/ha.d/haresources" do
mode 0644
source "haresources.erb"
end
 
service "heartbeat" do
action [ :enable, :start ]
end
templates/default/authkeys.erb
HTML+ERB
1 2
auth 1
1 md5 <%= @node[:heartbeat][:secret] %>
templates/default/ha.cf.erb
HTML+ERB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
logfacility local0
 
keepalive 250ms
deadtime 2
warntime 1
initdead 15
 
udpport <%= @node[:heartbeat][:port] %>
 
ucast <%= @node[:heartbeat][:interface] %> <%= @node[:heartbeat][:other_member] %>
 
auto_failback off
 
<% @node[:heartbeat][:nodes].each do |node| -%>
node <%= node %>
<% end -%>
templates/default/haresources.erb
HTML+ERB
1
<%= @node[:heartbeat][:haresources] %>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.