From aac71e8f95b47d0a8a34d63be283b708f57cda7c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 3 Nov 2011 02:14:57 +0000 Subject: [PATCH] * Add a module for DRBD. svn path=/nixos/trunk/; revision=30202 --- modules/module-list.nix | 1 + modules/services/network-filesystems/drbd.nix | 77 +++++++++++++++++++ .../activation/switch-to-configuration.sh | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 modules/services/network-filesystems/drbd.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 13e56dc8f68..6ba0c447aed 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -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 diff --git a/modules/services/network-filesystems/drbd.nix b/modules/services/network-filesystems/drbd.nix new file mode 100644 index 00000000000..1c70d44f6ba --- /dev/null +++ b/modules/services/network-filesystems/drbd.nix @@ -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 drbd.conf 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 + ''; + }; + + }; + +} diff --git a/modules/system/activation/switch-to-configuration.sh b/modules/system/activation/switch-to-configuration.sh index 2586d492d9e..3be1b210d6a 100644 --- a/modules/system/activation/switch-to-configuration.sh +++ b/modules/system/activation/switch-to-configuration.sh @@ -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..."