Skip to content

Instantly share code, notes, and snippets.

@joewilliams
Forked from macros/heartbeat.rb
Created August 4, 2009 00:04
Show Gist options
  • Save joewilliams/160910 to your computer and use it in GitHub Desktop.
Save joewilliams/160910 to your computer and use it in GitHub Desktop.
auth 1
1 md5 <%= @node[:heartbeat][:secret] %>
#
# 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
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 -%>
<%= @node[:heartbeat][:haresources] %>
#
# 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")
maintainer "Wikia, Inc."
maintainer_email "[email protected]"
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"
"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"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment