1{ lib, pkgs, ... }:
2let
3 confPath = "/etc/waagent.conf";
4in
5{
6 name = "waagent";
7
8 meta = {
9 maintainers = with lib.maintainers; [ codgician ];
10 };
11
12 nodes.machine = {
13 services.waagent = {
14 enable = true;
15 settings = {
16 Provisioning = {
17 Enable = false;
18 Agent = "waagent";
19 DeleteRootPassword = false;
20 RegenerateSshHostKeyPair = false;
21 SshHostKeyPairType = "ed25519";
22 MonitorHostName = false;
23 };
24 ResourceDisk = {
25 Format = false;
26 MountOptions = [
27 "compress=lzo"
28 "mode=0600"
29 ];
30 };
31 OS.RootDeviceScsiTimeout = 300;
32 HttpProxy = {
33 Host = null;
34 Port = null;
35 };
36 CGroups = {
37 EnforceLimits = false;
38 Excluded = [ ];
39 };
40 };
41 };
42 };
43
44 testScript = ''
45 # Defined values should be reflected in waagent.conf
46 machine.succeed("grep -q '^Provisioning.Enable=n$' '${confPath}'")
47 machine.succeed("grep -q '^Provisioning.Agent=waagent$' '${confPath}'")
48 machine.succeed("grep -q '^Provisioning.DeleteRootPassword=n$' '${confPath}'")
49 machine.succeed("grep -q '^Provisioning.RegenerateSshHostKeyPair=n$' '${confPath}'")
50 machine.succeed("grep -q '^Provisioning.SshHostKeyPairType=ed25519$' '${confPath}'")
51 machine.succeed("grep -q '^Provisioning.MonitorHostName=n$' '${confPath}'")
52 machine.succeed("grep -q '^ResourceDisk.Format=n$' '${confPath}'")
53 machine.succeed("grep -q '^ResourceDisk.MountOptions=compress=lzo,mode=0600$' '${confPath}'")
54 machine.succeed("grep -q '^OS.RootDeviceScsiTimeout=300$' '${confPath}'")
55
56 # Undocumented options should also be supported
57 machine.succeed("grep -q '^CGroups.EnforceLimits=n$' '${confPath}'")
58
59 # Null values should be skipped and not exist in waagent.conf
60 machine.fail("grep -q '^HttpProxy.Host=' '${confPath}'")
61 machine.fail("grep -q '^HttpProxy.Port=' '${confPath}'")
62
63 # Empty lists should be skipped and not exist in waagent.conf
64 machine.fail("grep -q '^CGroups.Excluded=' '${confPath}'")
65
66 # Test service start
67 # Skip testing actual functionality due to lacking Azure infrasturcture
68 machine.wait_for_unit("waagent.service")
69 '';
70}