admin: migrate to clan.nixosTests module
This commit is contained in:
@@ -1,17 +1,18 @@
|
|||||||
{ lib, self, ... }:
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
module = lib.modules.importApply ./default.nix { };
|
||||||
|
in
|
||||||
{
|
{
|
||||||
clan.modules = {
|
clan.modules = {
|
||||||
admin = lib.modules.importApply ./default.nix { };
|
admin = module;
|
||||||
};
|
};
|
||||||
perSystem =
|
perSystem =
|
||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
checks = lib.optionalAttrs (pkgs.stdenv.isLinux) {
|
clan.nixosTests.admin = {
|
||||||
admin = import ./tests/vm/default.nix {
|
imports = [ ./tests/vm/default.nix ];
|
||||||
inherit pkgs;
|
|
||||||
clan-core = self;
|
clan.modules."@clan/admin" = module;
|
||||||
nixosLib = import (self.inputs.nixpkgs + "/nixos/lib") { };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,45 @@
|
|||||||
{
|
|
||||||
pkgs,
|
|
||||||
nixosLib,
|
|
||||||
clan-core,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
public-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII6zj7ubTg6z/aDwRNwvM/WlQdUocMprQ8E92NWxl6t+ test@test";
|
public-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII6zj7ubTg6z/aDwRNwvM/WlQdUocMprQ8E92NWxl6t+ test@test";
|
||||||
in
|
in
|
||||||
nixosLib.runTest (
|
{
|
||||||
{ ... }:
|
name = "admin";
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
clan-core.modules.nixosVmTest.clanTest
|
|
||||||
];
|
|
||||||
|
|
||||||
hostPkgs = pkgs;
|
clan = {
|
||||||
|
directory = ./.;
|
||||||
|
inventory = {
|
||||||
|
|
||||||
name = "admin";
|
machines.client = { };
|
||||||
|
machines.server = { };
|
||||||
|
|
||||||
clan = {
|
instances = {
|
||||||
directory = ./.;
|
ssh-test-one = {
|
||||||
modules."@clan/admin" = ../../default.nix;
|
module.name = "@clan/admin";
|
||||||
inventory = {
|
roles.default.machines."server".settings = {
|
||||||
|
allowedKeys.testkey = public-key;
|
||||||
machines.client = { };
|
|
||||||
machines.server = { };
|
|
||||||
|
|
||||||
instances = {
|
|
||||||
ssh-test-one = {
|
|
||||||
module.name = "@clan/admin";
|
|
||||||
roles.default.machines."server".settings = {
|
|
||||||
allowedKeys.testkey = public-key;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
client.environment.etc.private-test-key.source = ./private-test-key;
|
client.environment.etc.private-test-key.source = ./private-test-key;
|
||||||
|
|
||||||
server = {
|
server = {
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
machines = [client, server]
|
machines = [client, server]
|
||||||
for m in machines:
|
for m in machines:
|
||||||
m.systemctl("start network-online.target")
|
m.systemctl("start network-online.target")
|
||||||
|
|
||||||
for m in machines:
|
for m in machines:
|
||||||
m.wait_for_unit("network-online.target")
|
m.wait_for_unit("network-online.target")
|
||||||
|
|
||||||
client.succeed(f"ssh -F /dev/null -i /etc/private-test-key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes root@server true &>/dev/null")
|
client.succeed(f"ssh -F /dev/null -i /etc/private-test-key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes root@server true &>/dev/null")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user