This cookbook is designed to setup and configure a pair of server with drbd. Please Note: this cookbook does not mount the drbd drive.
This cookbook can be used in the following situations:
1) Fresh server pair installation (please see below for how to use).
2) Adding a server to another server running drbd.
3) Change drbd.conf file and have drbd update with out restarting.
Prerequisites:
-
Chef client must be installed on both servers.
-
The disk location (node[:disk]) must exist.
-
The servers must be able to ssh to the other server.
Note: In order for this work properly both servers need to be running chef at the same time,
There are 2 ways to specify a drbd primary. 1) set an override attribute on the node directly “drbd”:{“master”=true} 2) set an attribute “server_letter” as ‘a’
Once one server has been specified as drbd master you can add the recipe “drbd::drbd_fresh_install” to the run_list of both servers.
This is the same as above except the new server is not specified as the drbd master, and you dont have to be running chef-client on the other server.
On which ever server you are updated (or both) add the recipe “drbd::drbd_inplace_upgrade” to the server’s run_list. And the next time Chef-client runs it will preform the changes in a safe way.
The ways I have used this have been to call this drbd cookbook from within another cookbook, and have the second cookbook do the logic of decided whether or not this is a fresh install or inplace upgrade.
Here is how I use it:
if system(" [ -f /etc/drbd.conf ] ") include_recipe "extended_drbd::drbd_inplace_upgrade" else include_recipe "extended_drbd::drbd_fresh_install" end
default[:packages] = [“kmod-drbd83”, “drbd83”]
default[:remote_host] = nil
default[:disk] = “/dev/local/data”
default[:mount] = “/data”
default[:fs_type] = “ext3”
default[:dev] = “/dev/drbd0”
default[:master] = false
default[:port] = 7789
default[:configured] = false
default[:stop_file] = “/etc/drbd_stop_file”
default[:syncrate] = “36M”
default[:resource] = “data”
default = ”
default =”
default = ”
default[:primary] = ‘a’
default[:secondary] = ‘b’
default = “”
DRBD Chef Recipe Copyright © 2012 Justin Witrick
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.