lol

nixos/waagent: init module (#362101)

authored by

Florian Klink and committed by
GitHub
4e7a971f 88cb8621

+508 -288
+4
nixos/doc/manual/release-notes/rl-2505.section.md
··· 30 30 31 31 - [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](options.html#opt-services.agorakit.enable). 32 32 33 + - [waagent](https://github.com/Azure/WALinuxAgent), the Microsoft Azure Linux Agent (waagent) manages Linux provisioning and VM interaction with the Azure Fabric Controller. Available with [services.waagent](options.html#opt-services.waagent.enable). 34 + 33 35 - [mqtt-exporter](https://github.com/kpetremann/mqtt-exporter/), a Prometheus exporter for exposing messages from MQTT. Available as [services.prometheus.exporters.mqtt](#opt-services.prometheus.exporters.mqtt.enable). 34 36 35 37 - [Buffyboard](https://gitlab.postmarketos.org/postmarketOS/buffybox/-/tree/master/buffyboard), a framebuffer on-screen keyboard. Available as [services.buffyboard](option.html#opt-services.buffyboard). ··· 103 105 - `gkraken` software and `hardware.gkraken.enable` option have been removed, use `coolercontrol` via `programs.coolercontrol.enable` option instead. 104 106 105 107 - `nodePackages.ganache` has been removed, as the package has been deprecated by upstream. 108 + 109 + - `virtualisation.azure.agent` option provided by `azure-agent.nix` is replaced by `services.waagent`, and will be removed in a future release. 106 110 107 111 - `containerd` has been updated to v2, which contains breaking changes. See the [containerd 108 112 2.0](https://github.com/containerd/containerd/blob/main/docs/containerd-2.0.md) documentation for more
+1
nixos/modules/module-list.nix
··· 1765 1765 ./virtualisation/virtualbox-host.nix 1766 1766 ./virtualisation/vmware-guest.nix 1767 1767 ./virtualisation/vmware-host.nix 1768 + ./virtualisation/waagent.nix 1768 1769 ./virtualisation/waydroid.nix 1769 1770 ./virtualisation/xe-guest-utilities.nix 1770 1771 ./virtualisation/xen-dom0.nix
+53 -288
nixos/modules/virtualisation/azure-agent.nix
··· 1 - { config, lib, pkgs, ... }: 1 + { lib, ... }: 2 2 3 3 with lib; 4 - let 5 - 6 - cfg = config.virtualisation.azure.agent; 7 - 8 - provisionedHook = pkgs.writeScript "provisioned-hook" '' 9 - #!${pkgs.runtimeShell} 10 - /run/current-system/systemd/bin/systemctl start provisioned.target 11 - ''; 12 - 13 - in 14 - { 4 + warn 5 + '' 6 + `virtualisation.azure.agent` provided by `azure-agent.nix` module has been replaced 7 + by `services.waagent` options, and will be removed in a future release. 8 + '' 9 + { 15 10 16 - ###### interface 17 - 18 - options.virtualisation.azure.agent = { 19 - enable = mkOption { 20 - default = false; 21 - description = "Whether to enable the Windows Azure Linux Agent."; 22 - }; 23 - verboseLogging = mkOption { 24 - default = false; 25 - description = "Whether to enable verbose logging."; 26 - }; 27 - mountResourceDisk = mkOption { 28 - default = true; 29 - description = "Whether the agent should format (ext4) and mount the resource disk to /mnt/resource."; 30 - }; 31 - }; 32 - 33 - ###### implementation 34 - 35 - config = lib.mkIf cfg.enable { 36 - assertions = [{ 37 - assertion = config.networking.networkmanager.enable == false; 38 - message = "Windows Azure Linux Agent is not compatible with NetworkManager"; 39 - }]; 40 - 41 - boot.initrd.kernelModules = [ "ata_piix" ]; 42 - networking.firewall.allowedUDPPorts = [ 68 ]; 43 - 44 - 45 - environment.etc."waagent.conf".text = '' 46 - # 47 - # Microsoft Azure Linux Agent Configuration 48 - # 49 - 50 - # Enable extension handling. Do not disable this unless you do not need password reset, 51 - # backup, monitoring, or any extension handling whatsoever. 52 - Extensions.Enabled=y 53 - 54 - # How often (in seconds) to poll for new goal states 55 - Extensions.GoalStatePeriod=6 56 - 57 - # Which provisioning agent to use. Supported values are "auto" (default), "waagent", 58 - # "cloud-init", or "disabled". 59 - Provisioning.Agent=auto 60 - 61 - # Password authentication for root account will be unavailable. 62 - Provisioning.DeleteRootPassword=n 63 - 64 - # Generate fresh host key pair. 65 - Provisioning.RegenerateSshHostKeyPair=n 66 - 67 - # Supported values are "rsa", "dsa", "ecdsa", "ed25519", and "auto". 68 - # The "auto" option is supported on OpenSSH 5.9 (2011) and later. 69 - Provisioning.SshHostKeyPairType=ed25519 70 - 71 - # Monitor host name changes and publish changes via DHCP requests. 72 - Provisioning.MonitorHostName=y 73 - 74 - # How often (in seconds) to monitor host name changes. 75 - Provisioning.MonitorHostNamePeriod=30 76 - 77 - # Decode CustomData from Base64. 78 - Provisioning.DecodeCustomData=n 79 - 80 - # Execute CustomData after provisioning. 81 - Provisioning.ExecuteCustomData=n 82 - 83 - # Algorithm used by crypt when generating password hash. 84 - #Provisioning.PasswordCryptId=6 85 - 86 - # Length of random salt used when generating password hash. 87 - #Provisioning.PasswordCryptSaltLength=10 88 - 89 - # Allow reset password of sys user 90 - Provisioning.AllowResetSysUser=n 91 - 92 - # Format if unformatted. If 'n', resource disk will not be mounted. 93 - ResourceDisk.Format=${if cfg.mountResourceDisk then "y" else "n"} 94 - 95 - # File system on the resource disk 96 - # Typically ext3 or ext4. FreeBSD images should use 'ufs2' here. 97 - ResourceDisk.Filesystem=ext4 98 - 99 - # Mount point for the resource disk 100 - ResourceDisk.MountPoint=/mnt/resource 101 - 102 - # Create and use swapfile on resource disk. 103 - ResourceDisk.EnableSwap=n 104 - 105 - # Size of the swapfile. 106 - ResourceDisk.SwapSizeMB=0 107 - 108 - # Comma-separated list of mount options. See mount(8) for valid options. 109 - ResourceDisk.MountOptions=None 110 - 111 - # Enable verbose logging (y|n) 112 - Logs.Verbose=${if cfg.verboseLogging then "y" else "n"} 113 - 114 - # Enable Console logging, default is y 115 - # Logs.Console=y 116 - 117 - # Enable periodic log collection, default is n 118 - Logs.Collect=n 119 - 120 - # How frequently to collect logs, default is each hour 121 - Logs.CollectPeriod=3600 122 - 123 - # Is FIPS enabled 124 - OS.EnableFIPS=n 125 - 126 - # Root device timeout in seconds. 127 - OS.RootDeviceScsiTimeout=300 128 - 129 - # How often (in seconds) to set the root device timeout. 130 - OS.RootDeviceScsiTimeoutPeriod=30 131 - 132 - # If "None", the system default version is used. 133 - OS.OpensslPath=${pkgs.openssl_3.bin}/bin/openssl 134 - 135 - # Set the SSH ClientAliveInterval 136 - # OS.SshClientAliveInterval=180 137 - 138 - # Set the path to SSH keys and configuration files 139 - OS.SshDir=/etc/ssh 140 - 141 - # If set, agent will use proxy server to access internet 142 - #HttpProxy.Host=None 143 - #HttpProxy.Port=None 144 - 145 - # Detect Scvmm environment, default is n 146 - # DetectScvmmEnv=n 147 - 148 - # 149 - # Lib.Dir=/var/lib/waagent 150 - 151 - # 152 - # DVD.MountPoint=/mnt/cdrom/secure 153 - 154 - # 155 - # Pid.File=/var/run/waagent.pid 156 - 157 - # 158 - # Extension.LogDir=/var/log/azure 159 - 160 - # 161 - # Home.Dir=/home 162 - 163 - # Enable RDMA management and set up, should only be used in HPC images 164 - OS.EnableRDMA=n 165 - 166 - # Enable checking RDMA driver version and update 167 - # OS.CheckRdmaDriver=y 168 - 169 - # Enable or disable goal state processing auto-update, default is enabled 170 - AutoUpdate.Enabled=n 171 - 172 - # Determine the update family, this should not be changed 173 - # AutoUpdate.GAFamily=Prod 174 - 175 - # Determine if the overprovisioning feature is enabled. If yes, hold extension 176 - # handling until inVMArtifactsProfile.OnHold is false. 177 - # Default is enabled 178 - EnableOverProvisioning=n 179 - 180 - # Allow fallback to HTTP if HTTPS is unavailable 181 - # Note: Allowing HTTP (vs. HTTPS) may cause security risks 182 - # OS.AllowHTTP=n 183 - 184 - # Add firewall rules to protect access to Azure host node services 185 - OS.EnableFirewall=n 186 - 187 - # How often (in seconds) to check the firewall rules 188 - OS.EnableFirewallPeriod=30 189 - 190 - # How often (in seconds) to remove the udev rules for persistent network interface 191 - # names (75-persistent-net-generator.rules and /etc/udev/rules.d/70-persistent-net.rules) 192 - OS.RemovePersistentNetRulesPeriod=30 193 - 194 - # How often (in seconds) to monitor for DHCP client restarts 195 - OS.MonitorDhcpClientRestartPeriod=30 196 - ''; 197 - 198 - services.udev.packages = [ pkgs.waagent ]; 199 - 200 - # Provide waagent-shipped udev rules in initrd too. 201 - boot.initrd.services.udev.packages = [ pkgs.waagent ]; 202 - # udev rules shell out to chmod, cut and readlink, which are all 203 - # provided by pkgs.coreutils, which is in services.udev.path, but not 204 - # boot.initrd.services.udev.binPackages. 205 - boot.initrd.services.udev.binPackages = [ pkgs.coreutils ]; 206 - 207 - networking.dhcpcd.persistent = true; 208 - 209 - services.logrotate = { 210 - enable = true; 211 - settings."/var/log/waagent.log" = { 212 - compress = true; 213 - frequency = "monthly"; 214 - rotate = 6; 215 - }; 216 - }; 217 - 218 - systemd.targets.provisioned = { 219 - description = "Services Requiring Azure VM provisioning to have finished"; 220 - }; 221 - 222 - systemd.services.consume-hypervisor-entropy = 223 - { 224 - description = "Consume entropy in ACPI table provided by Hyper-V"; 225 - 226 - wantedBy = [ "sshd.service" "waagent.service" ]; 227 - before = [ "sshd.service" "waagent.service" ]; 228 - 229 - path = [ pkgs.coreutils ]; 230 - script = 231 - '' 232 - echo "Fetching entropy..." 233 - cat /sys/firmware/acpi/tables/OEM0 > /dev/random 234 - ''; 235 - serviceConfig.Type = "oneshot"; 236 - serviceConfig.RemainAfterExit = true; 237 - serviceConfig.StandardError = "journal+console"; 238 - serviceConfig.StandardOutput = "journal+console"; 239 - }; 240 - 241 - systemd.services.waagent = { 242 - wantedBy = [ "multi-user.target" ]; 243 - after = [ "network-online.target" "sshd.service" ]; 244 - wants = [ "network-online.target" ]; 245 - 246 - path = [ 247 - pkgs.e2fsprogs 248 - pkgs.bash 249 - 250 - pkgs.findutils 251 - pkgs.gnugrep 252 - pkgs.gnused 253 - pkgs.iproute2 254 - pkgs.iptables 255 - 256 - # for hostname 257 - pkgs.nettools 258 - 259 - pkgs.openssh 260 - pkgs.openssl 261 - pkgs.parted 262 - 263 - # for pidof 264 - pkgs.procps 265 - 266 - # for useradd, usermod 267 - pkgs.shadow 268 - 269 - pkgs.util-linux # for (u)mount, fdisk, sfdisk, mkswap 270 - 271 - # waagent's Microsoft.OSTCExtensions.VMAccessForLinux needs Python 3 272 - pkgs.python39 273 - 274 - # waagent's Microsoft.CPlat.Core.RunCommandLinux needs lsof 275 - pkgs.lsof 276 - ]; 277 - description = "Windows Azure Agent Service"; 278 - unitConfig.ConditionPathExists = "/etc/waagent.conf"; 279 - serviceConfig = { 280 - ExecStart = "${pkgs.waagent}/bin/waagent -daemon"; 281 - Type = "simple"; 282 - }; 283 - }; 284 - 285 - # waagent will generate files under /etc/sudoers.d during provisioning 286 - security.sudo.extraConfig = '' 287 - #includedir /etc/sudoers.d 288 - ''; 289 - 290 - }; 291 - } 11 + imports = [ 12 + (mkRenamedOptionModule 13 + [ 14 + "virtualisation" 15 + "azure" 16 + "agent" 17 + "enable" 18 + ] 19 + [ 20 + "services" 21 + "waagent" 22 + "enable" 23 + ] 24 + ) 25 + (mkRenamedOptionModule 26 + [ 27 + "virtualisation" 28 + "azure" 29 + "agent" 30 + "verboseLogging" 31 + ] 32 + [ 33 + "services" 34 + "waagent" 35 + "settings" 36 + "Logs" 37 + "Verbose" 38 + ] 39 + ) 40 + (mkRenamedOptionModule 41 + [ 42 + "virtualisation" 43 + "azure" 44 + "agent" 45 + "mountResourceDisk" 46 + ] 47 + [ 48 + "services" 49 + "waagent" 50 + "settings" 51 + "ResourceDisk" 52 + "Format" 53 + ] 54 + ) 55 + ]; 56 + }
+364
nixos/modules/virtualisation/waagent.nix
··· 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + 8 + with lib; 9 + let 10 + cfg = config.services.waagent; 11 + 12 + # Format for waagent.conf 13 + settingsFormat = { 14 + type = 15 + with types; 16 + let 17 + singleAtom = 18 + (nullOr (oneOf [ 19 + bool 20 + str 21 + int 22 + float 23 + ])) 24 + // { 25 + description = "atom (bool, string, int or float) or null"; 26 + }; 27 + atom = either singleAtom (listOf singleAtom) // { 28 + description = singleAtom.description + " or a list of them"; 29 + }; 30 + in 31 + attrsOf ( 32 + either atom (attrsOf atom) 33 + // { 34 + description = atom.description + "or an attribute set of them"; 35 + } 36 + ); 37 + generate = 38 + name: value: 39 + let 40 + # Transform non-attribute values 41 + transform = 42 + x: 43 + # Transform bool to "y" or "n" 44 + if (isBool x) then 45 + (if x then "y" else "n") 46 + # Concatenate list items with comma 47 + else if (isList x) then 48 + concatStringsSep "," (map transform x) 49 + else 50 + toString x; 51 + 52 + # Convert to format of waagent.conf 53 + recurse = 54 + path: value: 55 + if builtins.isAttrs value then 56 + pipe value [ 57 + (mapAttrsToList (k: v: recurse (path ++ [ k ]) v)) 58 + concatLists 59 + ] 60 + else 61 + [ 62 + { 63 + name = concatStringsSep "." path; 64 + inherit value; 65 + } 66 + ]; 67 + convert = 68 + attrs: 69 + pipe (recurse [ ] attrs) [ 70 + # Filter out null values and emoty lists 71 + (filter (kv: kv.value != null && kv.value != [ ])) 72 + # Transform to Key=Value form, then concatenate 73 + (map (kv: "${kv.name}=${transform kv.value}")) 74 + (concatStringsSep "\n") 75 + ]; 76 + in 77 + pkgs.writeText name (convert value); 78 + }; 79 + 80 + settingsType = types.submodule { 81 + freeformType = settingsFormat.type; 82 + options = { 83 + Provisioning = { 84 + Enable = mkOption { 85 + type = types.bool; 86 + default = !config.services.cloud-init.enable; 87 + defaultText = literalExpression "!config.services.cloud-init.enable"; 88 + description = '' 89 + Whether to enable provisioning functionality in the agent. 90 + 91 + If provisioning is disabled, SSH host and user keys in the image are preserved 92 + and configuration in the Azure provisioning API is ignored. 93 + 94 + Set to `false` if cloud-init is used for provisioning tasks. 95 + ''; 96 + }; 97 + 98 + Agent = mkOption { 99 + type = types.enum [ 100 + "auto" 101 + "waagent" 102 + "cloud-init" 103 + "disabled" 104 + ]; 105 + default = "auto"; 106 + description = '' 107 + Which provisioning agent to use. 108 + ''; 109 + }; 110 + }; 111 + 112 + ResourceDisk = { 113 + Format = mkEnableOption '' 114 + If set to `true`, waagent formats and mounts the resource disk that the platform provides, 115 + unless the file system type in `ResourceDisk.FileSystem` is set to `ntfs`. 116 + The agent makes a single Linux partition (ID 83) available on the disk. 117 + This partition isn't formatted if it can be successfully mounted. 118 + 119 + This configuration has no effect if resource disk is managed by cloud-init. 120 + ''; 121 + 122 + FileSystem = mkOption { 123 + type = types.str; 124 + default = "ext4"; 125 + description = '' 126 + The file system type for the resource disk. 127 + If the string is `X`, then `mkfs.X` should be present in the environment. 128 + You can add additional filesystem packages using `services.waagent.extraPackages`. 129 + 130 + This configuration has no effect if resource disk is managed by cloud-init. 131 + ''; 132 + }; 133 + 134 + MountPoint = mkOption { 135 + type = types.str; 136 + default = "/mnt/resource"; 137 + description = '' 138 + This option specifies the path at which the resource disk is mounted. 139 + The resource disk is a temporary disk and might be emptied when the VM is deprovisioned. 140 + 141 + This configuration has no effect if resource disk is managed by cloud-init. 142 + ''; 143 + }; 144 + 145 + MountOptions = mkOption { 146 + type = with types; listOf str; 147 + default = [ ]; 148 + example = [ 149 + "nodev" 150 + "nosuid" 151 + ]; 152 + description = '' 153 + This option specifies disk mount options to be passed to the `mount -o` command. 154 + For more information, see the `mount(8)` manual page. 155 + ''; 156 + }; 157 + 158 + EnableSwap = mkEnableOption '' 159 + If enabled, the agent creates a swap file (`/swapfile`) on the resource disk 160 + and adds it to the system swap space. 161 + 162 + This configuration has no effect if resource disk is managed by cloud-init. 163 + ''; 164 + 165 + SwapSizeMB = mkOption { 166 + type = types.int; 167 + default = 0; 168 + description = '' 169 + Specifies the size of the swap file in megabytes. 170 + 171 + This configuration has no effect if resource disk is managed by cloud-init. 172 + ''; 173 + }; 174 + }; 175 + 176 + Logs.Verbose = lib.mkEnableOption '' 177 + If you set this option, log verbosity is boosted. 178 + Waagent logs to `/var/log/waagent.log` and uses the system logrotate functionality to rotate logs. 179 + ''; 180 + 181 + OS = { 182 + EnableRDMA = lib.mkEnableOption '' 183 + If enabled, the agent attempts to install and then load an RDMA kernel driver 184 + that matches the version of the firmware on the underlying hardware. 185 + ''; 186 + 187 + RootDeviceScsiTimeout = lib.mkOption { 188 + type = types.nullOr types.int; 189 + default = 300; 190 + description = '' 191 + Configures the SCSI timeout in seconds on the OS disk and data drives. 192 + If set to `null`, the system defaults are used. 193 + ''; 194 + }; 195 + }; 196 + 197 + HttpProxy = { 198 + Host = lib.mkOption { 199 + type = types.nullOr types.str; 200 + default = null; 201 + description = '' 202 + If you set http proxy, waagent will use is proxy to access the Internet. 203 + ''; 204 + }; 205 + 206 + Port = lib.mkOption { 207 + type = types.nullOr types.int; 208 + default = null; 209 + description = '' 210 + If you set http proxy, waagent will use this proxy to access the Internet. 211 + ''; 212 + }; 213 + }; 214 + 215 + AutoUpdate.Enable = lib.mkEnableOption '' 216 + Enable or disable autoupdate for goal state processing. 217 + ''; 218 + }; 219 + }; 220 + in 221 + { 222 + options.services.waagent = { 223 + enable = lib.mkEnableOption '' 224 + Whether to enable the Windows Azure Linux Agent. 225 + ''; 226 + 227 + package = lib.mkPackageOption pkgs "waagent" { }; 228 + 229 + extraPackages = lib.mkOption { 230 + default = [ ]; 231 + description = '' 232 + Additional packages to add to the waagent {env}`PATH`. 233 + ''; 234 + example = lib.literalExpression "[ pkgs.powershell ]"; 235 + type = lib.types.listOf lib.types.package; 236 + }; 237 + 238 + settings = lib.mkOption { 239 + type = settingsType; 240 + default = { }; 241 + description = '' 242 + The waagent.conf configuration, see https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/agent-linux for documentation. 243 + ''; 244 + }; 245 + }; 246 + 247 + config = lib.mkIf cfg.enable { 248 + assertions = [ 249 + { 250 + assertion = (cfg.settings.HttpProxy.Host != null) -> (cfg.settings.HttpProxy.Port != null); 251 + message = "Option services.waagent.settings.HttpProxy.Port must be set if services.waagent.settings.HttpProxy.Host is set."; 252 + } 253 + ]; 254 + 255 + boot.initrd.kernelModules = [ "ata_piix" ]; 256 + networking.firewall.allowedUDPPorts = [ 68 ]; 257 + 258 + services.udev.packages = with pkgs; [ waagent ]; 259 + 260 + boot.initrd.services.udev = with pkgs; { 261 + # Provide waagent-shipped udev rules in initrd too. 262 + packages = [ waagent ]; 263 + # udev rules shell out to chmod, cut and readlink, which are all 264 + # provided by pkgs.coreutils, which is in services.udev.path, but not 265 + # boot.initrd.services.udev.binPackages. 266 + binPackages = [ coreutils ]; 267 + }; 268 + 269 + networking.dhcpcd.persistent = true; 270 + 271 + services.logrotate = { 272 + enable = true; 273 + settings."/var/log/waagent.log" = { 274 + compress = true; 275 + frequency = "monthly"; 276 + rotate = 6; 277 + }; 278 + }; 279 + 280 + # Write settings to /etc/waagent.conf 281 + environment.etc."waagent.conf".source = settingsFormat.generate "waagent.conf" cfg.settings; 282 + 283 + systemd.targets.provisioned = { 284 + description = "Services Requiring Azure VM provisioning to have finished"; 285 + }; 286 + 287 + systemd.services.consume-hypervisor-entropy = { 288 + description = "Consume entropy in ACPI table provided by Hyper-V"; 289 + 290 + wantedBy = [ 291 + "sshd.service" 292 + "waagent.service" 293 + ]; 294 + before = [ 295 + "sshd.service" 296 + "waagent.service" 297 + ]; 298 + 299 + path = [ pkgs.coreutils ]; 300 + script = '' 301 + echo "Fetching entropy..." 302 + cat /sys/firmware/acpi/tables/OEM0 > /dev/random 303 + ''; 304 + serviceConfig.Type = "oneshot"; 305 + serviceConfig.RemainAfterExit = true; 306 + serviceConfig.StandardError = "journal+console"; 307 + serviceConfig.StandardOutput = "journal+console"; 308 + }; 309 + 310 + systemd.services.waagent = { 311 + wantedBy = [ "multi-user.target" ]; 312 + after = [ 313 + "network-online.target" 314 + ] ++ lib.optionals config.services.cloud-init.enable [ "cloud-init.service" ]; 315 + wants = [ 316 + "network-online.target" 317 + "sshd.service" 318 + "sshd-keygen.service" 319 + ]; 320 + 321 + path = 322 + with pkgs; 323 + [ 324 + e2fsprogs 325 + bash 326 + findutils 327 + gnugrep 328 + gnused 329 + iproute2 330 + iptables 331 + openssh 332 + openssl 333 + parted 334 + 335 + # for hostname 336 + nettools 337 + # for pidof 338 + procps 339 + # for useradd, usermod 340 + shadow 341 + 342 + util-linux # for (u)mount, fdisk, sfdisk, mkswap 343 + # waagent's Microsoft.CPlat.Core.RunCommandLinux needs lsof 344 + lsof 345 + ] 346 + ++ cfg.extraPackages; 347 + description = "Windows Azure Agent Service"; 348 + unitConfig.ConditionPathExists = "/etc/waagent.conf"; 349 + serviceConfig = { 350 + ExecStart = "${lib.getExe cfg.package} -daemon"; 351 + Type = "simple"; 352 + Restart = "always"; 353 + Slice = "azure.slice"; 354 + CPUAccounting = true; 355 + MemoryAccounting = true; 356 + }; 357 + }; 358 + 359 + # waagent will generate files under /etc/sudoers.d during provisioning 360 + security.sudo.extraConfig = '' 361 + #includedir /etc/sudoers.d 362 + ''; 363 + }; 364 + }
+1
nixos/tests/all-tests.nix
··· 1124 1124 vscode-remote-ssh = handleTestOn ["x86_64-linux"] ./vscode-remote-ssh.nix {}; 1125 1125 vscodium = discoverTests (import ./vscodium.nix); 1126 1126 vsftpd = handleTest ./vsftpd.nix {}; 1127 + waagent = handleTest ./waagent.nix {}; 1127 1128 wakapi = handleTest ./wakapi.nix {}; 1128 1129 warzone2100 = handleTest ./warzone2100.nix {}; 1129 1130 wasabibackend = handleTest ./wasabibackend.nix {};
+72
nixos/tests/waagent.nix
··· 1 + import ./make-test-python.nix ( 2 + { lib, pkgs, ... }: 3 + let 4 + confPath = "/etc/waagent.conf"; 5 + in 6 + { 7 + name = "waagent"; 8 + 9 + meta = { 10 + maintainers = with lib.maintainers; [ codgician ]; 11 + }; 12 + 13 + nodes.machine = { 14 + services.waagent = { 15 + enable = true; 16 + settings = { 17 + Provisioning = { 18 + Enable = false; 19 + Agent = "waagent"; 20 + DeleteRootPassword = false; 21 + RegenerateSshHostKeyPair = false; 22 + SshHostKeyPairType = "ed25519"; 23 + MonitorHostName = false; 24 + }; 25 + ResourceDisk = { 26 + Format = false; 27 + MountOptions = [ 28 + "compress=lzo" 29 + "mode=0600" 30 + ]; 31 + }; 32 + OS.RootDeviceScsiTimeout = 300; 33 + HttpProxy = { 34 + Host = null; 35 + Port = null; 36 + }; 37 + CGroups = { 38 + EnforceLimits = false; 39 + Excluded = [ ]; 40 + }; 41 + }; 42 + }; 43 + }; 44 + 45 + testScript = '' 46 + # Defined values should be reflected in waagent.conf 47 + machine.succeed("grep -q '^Provisioning.Enable=n$' '${confPath}'") 48 + machine.succeed("grep -q '^Provisioning.Agent=waagent$' '${confPath}'") 49 + machine.succeed("grep -q '^Provisioning.DeleteRootPassword=n$' '${confPath}'") 50 + machine.succeed("grep -q '^Provisioning.RegenerateSshHostKeyPair=n$' '${confPath}'") 51 + machine.succeed("grep -q '^Provisioning.SshHostKeyPairType=ed25519$' '${confPath}'") 52 + machine.succeed("grep -q '^Provisioning.MonitorHostName=n$' '${confPath}'") 53 + machine.succeed("grep -q '^ResourceDisk.Format=n$' '${confPath}'") 54 + machine.succeed("grep -q '^ResourceDisk.MountOptions=compress=lzo,mode=0600$' '${confPath}'") 55 + machine.succeed("grep -q '^OS.RootDeviceScsiTimeout=300$' '${confPath}'") 56 + 57 + # Undocumented options should also be supported 58 + machine.succeed("grep -q '^CGroups.EnforceLimits=n$' '${confPath}'") 59 + 60 + # Null values should be skipped and not exist in waagent.conf 61 + machine.fail("grep -q '^HttpProxy.Host=' '${confPath}'") 62 + machine.fail("grep -q '^HttpProxy.Port=' '${confPath}'") 63 + 64 + # Empty lists should be skipped and not exist in waagent.conf 65 + machine.fail("grep -q '^CGroups.Excluded=' '${confPath}'") 66 + 67 + # Test service start 68 + # Skip testing actual functionality due to lacking Azure infrasturcture 69 + machine.wait_for_unit("waagent.service") 70 + ''; 71 + } 72 + )
+13
pkgs/by-name/wa/waagent/package.nix
··· 4 4 lib, 5 5 python3, 6 6 bash, 7 + gitUpdater, 8 + nixosTests, 7 9 }: 8 10 9 11 let ··· 63 65 64 66 dontWrapPythonPrograms = false; 65 67 68 + passthru = { 69 + tests = { 70 + inherit (nixosTests) waagent; 71 + }; 72 + updateScript = gitUpdater { 73 + rev-prefix = "v"; 74 + }; 75 + }; 76 + 66 77 meta = { 67 78 description = "Microsoft Azure Linux Agent (waagent)"; 68 79 mainProgram = "waagent"; ··· 71 82 manages Linux provisioning and VM interaction with the Azure 72 83 Fabric Controller''; 73 84 homepage = "https://github.com/Azure/WALinuxAgent"; 85 + maintainers = with lib.maintainers; [ codgician ]; 74 86 license = with lib.licenses; [ asl20 ]; 87 + platforms = lib.platforms.linux; 75 88 }; 76 89 }