* Add a module for DRBD.

svn path=/nixos/trunk/; revision=30202
This commit is contained in:
Eelco Dolstra 2011-11-03 02:14:57 +00:00
parent 0309f02fc5
commit aac71e8f95
3 changed files with 79 additions and 1 deletions

View File

@ -96,6 +96,7 @@
./services/monitoring/systemhealth.nix
./services/monitoring/zabbix-agent.nix
./services/monitoring/zabbix-server.nix
./services/network-filesystems/drbd.nix
./services/network-filesystems/nfs-kernel.nix
./services/network-filesystems/openafs-client/default.nix
./services/network-filesystems/samba.nix

View File

@ -0,0 +1,77 @@
# Support for DRBD, the Distributed Replicated Block Device.
{ config, pkgs, ... }:
with pkgs.lib;
let cfg = config.services.drbd; in
{
###### interface
options = {
services.drbd.enable = mkOption {
default = false;
type = types.bool;
description = ''
Whether to enable support for DRBD, the Distributed Replicated
Block Device.
'';
};
services.drbd.config = mkOption {
default = "";
type = types.string;
description = ''
Contents of the <filename>drbd.conf</filename> configuration file.
'';
};
};
###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.drbd ];
services.udev.packages = [ pkgs.drbd ];
boot.kernelModules = [ "drbd" ];
boot.extraModprobeConfig =
''
options drbd usermode_helper=/var/run/current-system/sw/sbin/drbdadm
'';
environment.etc = singleton
{ source = pkgs.writeText "drbd.conf" cfg.config;
target = "drbd.conf";
};
jobs.drbd_up =
{ name = "drbd-up";
startOn = "stopped udevtrigger or ip-up";
task = true;
script =
''
${pkgs.drbd}/sbin/drbdadm up all
'';
};
jobs.drbd_down =
{ name = "drbd-down";
startOn = "starting shutdown";
task = true;
script =
''
${pkgs.drbd}/sbin/drbdadm down all
'';
};
};
}

View File

@ -114,7 +114,7 @@ EOF
# Xen domains unless we have to.
# TODO: Jobs should be able to declare that they should not be
# auto-restarted.
if echo "$job" | grep -q "^shutdown$\|^control-alt-delete$\|^xserver$\|^dbus$\|^disnix$\|^emergency-shell$\|^xendomains$\|^udevtrigger$"; then continue; fi
if echo "$job" | grep -q "^shutdown$\|^control-alt-delete$\|^xserver$\|^dbus$\|^disnix$\|^emergency-shell$\|^xendomains$\|^udevtrigger$\|^drbd-down$"; then continue; fi
if ! test -e "$oldJobs/$job.conf"; then
echo "starting $job..."