Skip to content

Commit f5ce58d

Browse files
jfrochesamrose
authored andcommitted
fix: configure basic ssh config file
Enabling the nginx service in the system configuration was a good start, but it had implications for the test suite verifying that the AMI was correctly configured. We change the configuration to set up a basic ssh config file that matches the expected configuration for the AMI, and update the tests to verify that the file is created with the correct content and permissions.
1 parent 1148db8 commit f5ce58d

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

nix/systemConfigs.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{ self, inputs, ... }:
22
let
33
mkModules = system: [
4+
self.systemModules.ssh-config
45
({
5-
services.nginx.enable = true;
66
nixpkgs.hostPlatform = system;
77
})
88
];

nix/systemModules/default.nix

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
{
2-
flake-parts-lib,
3-
withSystem,
4-
self,
52
...
63
}:
74
{
85
imports = [ ./tests ];
96
flake = {
107
systemModules = {
11-
nginx = flake-parts-lib.importApply ./nginx.nix { inherit withSystem self; };
8+
ssh-config = {
9+
environment.etc."ssh/sshd_config.d/local.conf" = {
10+
text = ''
11+
Match Address 127.0.0.1,::1
12+
ForceCommand /bin/false
13+
DisableForwarding yes
14+
PermitTunnel no
15+
'';
16+
user = "root";
17+
group = "root";
18+
mode = "0644";
19+
};
20+
};
1221
};
1322
};
1423
}

nix/systemModules/tests/default.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
machine.activate()
2525
machine.wait_for_unit("system-manager.target")
2626
27-
with subtest("Verify nginx service"):
28-
assert machine.service("nginx").is_running, "nginx should be running"
27+
with subtest("Verify ssh config"):
28+
assert machine.file("/etc/ssh/sshd_config.d/local.conf").exists, "/etc/ssh/sshd_config.d/local.conf should exist"
29+
assert machine.file("/etc/ssh/sshd_config.d/local.conf").mode == 0o644, "/etc/ssh/sshd_config.d/local.conf should have mode 0644"
30+
assert machine.file("/etc/ssh/sshd_config.d/local.conf").user == "root", "/etc/ssh/sshd_config.d/local.conf should be owned by root"
31+
assert machine.file("/etc/ssh/sshd_config.d/local.conf").group == "root", "/etc/ssh/sshd_config.d/local.conf should be owned by root"
32+
assert machine.file("/etc/ssh/sshd_config.d/local.conf").contains("Match Address"), "/etc/ssh/sshd_config.d/local.conf should contain 'Match Address'"
2933
'';
3034
};
3135
};

0 commit comments

Comments
 (0)