This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

template and package installation

  • Loading branch information...
mattray committed Sep 23, 2011
1 parent 47ab4b5 commit ee6294ab4c942cc359040de58ad809e57b2578ef
View
@@ -2,11 +2,13 @@ Description
===========
Installs and configures the Distributed Replicated Block Device (DRBD) service for mirroring block devices between a pair of hosts. Right now it simply works in pairs, multiple hosts could be supported with a few small changes.
+The `drbd` cookbook does not partition drives. It will format partitions given a filesystem type, but it does not explicitly depend on the `xfs` cookbook if you want that type of filesystem, but you can put it in your run list and set the node['drbd']['fs_type'] to 'xfs'.
+
Requirements
============
Platform
--------
-Tested with Ubuntu 10.04 and 10.10.
+Tested with Ubuntu 10.04 - 11.04. You must be running the 'linux-image-server' kernel because it contains the drbd module.
Recipes
=======
View
@@ -1,3 +1,10 @@
-default[:drbd][:host] = ""
-default[:drbd][:mount] = ""
+default[:drbd][:remote_host] = nil
+default[:drbd][:remote_ip] = nil
+default[:drbd][:disk] = nil
+default[:drbd][:mount] = nil
+default[:drbd][:fs_type] = nil
+default[:drbd][:dev] = "/dev/drbd1"
default[:drbd][:master] = true
+default[:drbd][:port] = 7789
+
+
@@ -0,0 +1,15 @@
+name "drbd-pair"
+description "DRBD pair role."
+
+override_attributes(
+ "drbd" => {
+ "disk" => "/dev/sdb",
+ "fs_type" => "xfs",
+ "mount" => "/drbd"
+ }
+ )
+
+run_list(
+ "recipe[xfs]",
+ "recipe[drbd::pair]"
+ )
View
@@ -4,7 +4,7 @@
description "Installs/Configures drbd."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.8.0"
-depends "lvm"
+#depends "lvm"
%w{ debian ubuntu }.each do |os|
supports os
View
@@ -23,10 +23,12 @@
action :install
end
+#install the kernel-module
+
service "drbd" do
supports(
:restart => true,
:status => true
)
- action :enable
+ action :nothing
end
View
@@ -20,3 +20,48 @@
include_recipe "drbd"
+#if remote host is blank, search for partner
+if node['drbd']['remote_host'].nil?
+ remotes = search(:node, 'drbd:*') || []
+ remotes.each do |remote|
+ Chef::Log.info "drbd::pair remotes #{remote.name}"
+ unless remote.name.equal?(node.name)
+ Chef::Log.info "drbd::pair found #{remote.name}"
+ node['drbd']['remote_host'] = remote.name
+ node['drbd']['remote_ip'] = remote.ipaddress
+ end
+ end
+end
+
+template "/etc/drbd.d/pair.res" do
+ source "res.erb"
+ variables( :mount => "pair" )
+ owner "root"
+ group "root"
+ not_if { node['drbd']['remote_host'].nil? }
+ #notifies :restart, resources(:service => "drbd"), :immediate
+end
+
+#first pass only, initialize drbd
+#drbdadm create-md resource
+
+#drbdadm up resource
+
+#cat /proc/drbd to see state
+#drbd-overview
+
+#select the initial sync source, key off of node['drbd']['master']
+#if not master, wait for search to return a master
+
+#if you are the master
+#drbdadm primary --force resource
+
+#You may now create a filesystem on the device, use it as a raw block device, mount it, and perform any other operation you would with an accessible block device.
+#package xfsprogs
+#mkfs -t node['drbd']['fs_type'] node['drbd']['dev']
+
+# mount node['drbd']['mount'] do
+# device node['drbd']['dev']
+# fstype node['drbd']['fs_type']
+# options "rw"
+# end
@@ -1,27 +0,0 @@
-# Generated by Chef for <%= node[:fqdn] %>
-
-global { usage-count no; }
-common { syncer { rate 100M; } }
-resource r0 {
- protocol C;
- startup {
- wfc-timeout 15;
- degr-wfc-timeout 60;
- }
- net {
- cram-hmac-alg sha1;
- shared-secret "secret";
- }
- on drbd01 {
- device /dev/drbd0;
- disk /dev/sdb1;
- address 192.168.0.1:7788;
- meta-disk internal;
- }
- on drbd02 {
- device /dev/drbd0;
- disk /dev/sdb1;
- address 192.168.0.2:7788;
- meta-disk internal;
- }
-}
@@ -0,0 +1,13 @@
+# Generated by Chef for <%= node[:fqdn] %>
+
+resource <%= @mount %> {
+ device <%= node['drbd']['dev'] %>;
+ disk <%= node['drbd']['disk'] %>;
+ meta-disk internal;
+ on <%= node.name %> {
+ address <%= node.ipaddress %>:<%= node['drbd']['port'] %>;
+ }
+ on <%= node['drbd']['remote_host'] %> {
+ address <%= node['drbd']['remote_ip'] %>:<%= node['drbd']['port'] %>;
+ }
+}

0 comments on commit ee6294a

Please sign in to comment.