Author: eelco
Date: Thu Apr 28 14:57:29 2011
New Revision: 27033
URL: https://svn.nixos.org/websvn/nix/?rev=27033&sc=1
Log:
* Activate configurations on remote machines.
Modified:
cloud/trunk/examples/apache.nix
cloud/trunk/src/eval-machine-info.nix
cloud/trunk/src/nixos-deploy-network.pl
Modified: cloud/trunk/examples/apache.nix
==============================================================================
--- cloud/trunk/examples/apache.nix Thu Apr 28 13:39:42 2011 (r27032)
+++ cloud/trunk/examples/apache.nix Thu Apr 28 14:57:29 2011 (r27033)
@@ -4,10 +4,8 @@
{ config, pkgs, ... }:
{
- services.openssh.enable = true;
-
services.httpd.enable = true;
- services.httpd.adminAddr = "[email protected]";
+ services.httpd.adminAddr = "[email protected]";
services.httpd.documentRoot = "${pkgs.valgrind}/share/doc/valgrind/html";
};
Modified: cloud/trunk/src/eval-machine-info.nix
==============================================================================
--- cloud/trunk/src/eval-machine-info.nix Thu Apr 28 13:39:42 2011
(r27032)
+++ cloud/trunk/src/eval-machine-info.nix Thu Apr 28 14:57:29 2011
(r27033)
@@ -6,17 +6,44 @@
with import "${nixos}/lib/testing.nix" { inherit nixpkgs system; };
with pkgs;
+with lib;
rec {
- x = complete { nodes = import networkExpr; testScript = ""; };
-
- machineInfo = builtins.attrNames (x.nodes);
+
+ network = import networkExpr;
+
+ nodes =
+ listToAttrs (map (configurationName:
+ let
+ configuration = getAttr configurationName network;
+ in
+ { name = configurationName;
+ value = import "${nixos}/lib/eval-config.nix" {
+ inherit nixpkgs;
+ modules =
+ [ configuration
+ # Slurp in the required configuration for machines in the adhoc
cloud.
+ /home/eelco/Dev/configurations/tud/cloud/cloud-vm.nix
+ # Provide a default hostname and deployment target equal
+ # to the attribute name of the machine in the model.
+ { key = "set-default-hostname";
+ networking.hostName = pkgs.lib.mkOverride 900
configurationName;
+ deployment.targetHost = pkgs.lib.mkOverride 900
configurationName;
+ networking.firewall.enable = pkgs.lib.mkOverride 900 false; #
hack, think about this later
+ }
+ ];
+ extraArgs = { inherit nodes; };
+ };
+ }
+ ) (attrNames network));
+
+ machineInfo = builtins.attrNames nodes;
machines = runCommand "vms" {}
''
mkdir -p $out
${toString (lib.attrValues (lib.mapAttrs (n: v: ''
- ln -s ${v.config.system.build.vm} $out/${n}
- '') x.nodes))}
+ ln -s ${v.config.system.build.toplevel} $out/${n}
+ '') nodes))}
'';
}
Modified: cloud/trunk/src/nixos-deploy-network.pl
==============================================================================
--- cloud/trunk/src/nixos-deploy-network.pl Thu Apr 28 13:39:42 2011
(r27032)
+++ cloud/trunk/src/nixos-deploy-network.pl Thu Apr 28 14:57:29 2011
(r27033)
@@ -102,15 +102,23 @@
# !!! Should copy closures in parallel.
foreach my $machine (@machines) {
print STDERR "copying closure to machine ‘$machine->{name}’...\n";
- my $systemPath = readlink "$outPath/$machine->{name}/system" or die;
- system "nix-copy-closure --gzip --to root\@$machine->{ipv6}
$systemPath";
+ my $toplevel = readlink "$outPath/$machine->{name}" or die;
+ $machine->{toplevel} = $toplevel;
+ system "nix-copy-closure --gzip --to root\@$machine->{ipv6} $toplevel";
die "unable to copy closure to machine ‘$machine->{name}’" unless $?
== 0;
}
}
sub activateConfigs {
- # TODO
+ foreach my $machine (@machines) {
+ print STDERR "activating new configuration on machine
‘$machine->{name}’...\n";
+ system "ssh -o StrictHostKeyChecking=no root\@$machine->{ipv6} nix-env
-p /nix/var/nix/profiles/system --set $machine->{toplevel} \\;
/nix/var/nix/profiles/system/bin/switch-to-configuration switch";
+ if ($? != 0) {
+ # !!! do a rollback
+ die "unable to activate new configuration on machine
‘$machine->{name}’";
+ }
+ }
}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits