nixos/lxd: add preseed option

This commit is contained in:
Adam Stephens
2023-09-04 11:58:53 -04:00
committed by Anderson Torres
parent 85c14ff2ff
commit a90385c62b
4 changed files with 150 additions and 0 deletions

View File

@@ -49,6 +49,9 @@ in {
# Wait for lxd to settle
machine.succeed("lxd waitready")
# no preseed should mean no service
machine.fail("systemctl status lxd-preseed.service")
machine.succeed("lxd init --minimal")
machine.succeed(

View File

@@ -5,6 +5,7 @@
}: {
container = import ./container.nix {inherit system pkgs;};
nftables = import ./nftables.nix {inherit system pkgs;};
preseed = import ./preseed.nix {inherit system pkgs;};
ui = import ./ui.nix {inherit system pkgs;};
virtual-machine = import ./virtual-machine.nix { inherit system pkgs; };
}

View File

@@ -0,0 +1,71 @@
import ../make-test-python.nix ({ pkgs, lib, ... } :
{
name = "lxd-preseed";
meta = {
maintainers = with lib.maintainers; [ adamcstephens ];
};
nodes.machine = { lib, ... }: {
virtualisation = {
diskSize = 4096;
lxc.lxcfs.enable = true;
lxd.enable = true;
lxd.preseed = {
networks = [
{
name = "nixostestbr0";
type = "bridge";
config = {
"ipv4.address" = "10.0.100.1/24";
"ipv4.nat" = "true";
};
}
];
profiles = [
{
name = "nixostest_default";
devices = {
eth0 = {
name = "eth0";
network = "nixostestbr0";
type = "nic";
};
root = {
path = "/";
pool = "default";
size = "35GiB";
type = "disk";
};
};
}
];
storage_pools = [
{
name = "nixostest_pool";
driver = "dir";
}
];
};
};
};
testScript = ''
def wait_for_preseed(_) -> bool:
_, output = machine.systemctl("is-active lxd-preseed.service")
return ("inactive" in output)
machine.wait_for_unit("sockets.target")
machine.wait_for_unit("lxd.service")
with machine.nested("Waiting for preseed to complete"):
retry(wait_for_preseed)
with subtest("Verify preseed resources created"):
machine.succeed("lxc profile show nixostest_default")
machine.succeed("lxc network info nixostestbr0")
machine.succeed("lxc storage show nixostest_pool")
'';
})