Skip to content

Commit 6018cf4

Browse files
committedFeb 27, 2017
amazon-init.service: fix starting services at startup
We now make it happen later in the boot process so that multi-user has already activated, so as to not run afoul of the logic in switch-to-configuration.pl. It's not my favorite solution, but at least it works. Also added a check to the VM test to catch the failure so we don't break in future. Fixes #23121
1 parent bccac38 commit 6018cf4

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed
 

Diff for: ‎nixos/modules/virtualisation/amazon-init.nix

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ in {
4545
inherit script;
4646
description = "Reconfigure the system from EC2 userdata on startup";
4747

48-
wantedBy = [ "sshd.service" ];
49-
before = [ "sshd.service" ];
50-
after = [ "network-online.target" ];
48+
wantedBy = [ "multi-user.target" ];
49+
after = [ "multi-user.target" ];
5150
requires = [ "network-online.target" ];
5251

5352
restartIfChanged = false;

Diff for: ‎nixos/tests/ec2.nix

+19-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ let
2525
# access. Mostly copied from
2626
# modules/profiles/installation-device.nix.
2727
system.extraDependencies =
28-
[ pkgs.stdenv pkgs.busybox pkgs.perlPackages.ArchiveCpio
29-
pkgs.unionfs-fuse pkgs.mkinitcpio-nfs-utils
28+
with pkgs; [
29+
stdenv busybox perlPackages.ArchiveCpio unionfs-fuse mkinitcpio-nfs-utils
30+
31+
# These are used in the configure-from-userdata tests for EC2. Httpd and valgrind are requested
32+
# directly by the configuration we set, and libxslt.bin is used indirectly as a build dependency
33+
# of the derivation for dbus configuration files.
34+
apacheHttpd valgrind.doc libxslt.bin
3035
];
3136
}
3237
];
@@ -137,6 +142,8 @@ in {
137142

138143
# ### http://nixos.org/channels/nixos-unstable nixos
139144
userData = ''
145+
{ pkgs, ... }:
146+
140147
{
141148
imports = [
142149
<nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
@@ -146,12 +153,22 @@ in {
146153
environment.etc.testFile = {
147154
text = "whoa";
148155
};
156+
157+
services.httpd = {
158+
enable = true;
159+
adminAddr = "test@example.org";
160+
documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
161+
};
162+
networking.firewall.allowedTCPPorts = [ 80 ];
149163
}
150164
'';
151165
script = ''
152166
$machine->start;
153167
$machine->waitForFile("/etc/testFile");
154168
$machine->succeed("cat /etc/testFile | grep -q 'whoa'");
169+
170+
$machine->waitForUnit("httpd.service");
171+
$machine->succeed("curl http://localhost | grep Valgrind");
155172
'';
156173
};
157174
}

0 commit comments

Comments
 (0)
Please sign in to comment.