From 02ef7e861b70170e977789c533916a540a2872b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Thu, 5 Dec 2024 18:35:06 +0100 Subject: [PATCH] Add qemu guest agent to all VMs --- common/vm/default.nix | 6 ++++++ common/vm/qemu-guest.nix | 4 ++++ hosts/ca/configuration.nix | 1 + hosts/ha1/configuration.nix | 23 +++++++++++++++-------- hosts/http-proxy/configuration.nix | 1 + hosts/monitoring01/configuration.nix | 3 +++ hosts/ns1/configuration.nix | 27 +++++++++++++++++---------- hosts/ns2/configuration.nix | 27 +++++++++++++++++---------- system/monitoring/metrics.nix | 2 ++ 9 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 common/vm/default.nix create mode 100644 common/vm/qemu-guest.nix diff --git a/common/vm/default.nix b/common/vm/default.nix new file mode 100644 index 0000000..c02fc0d --- /dev/null +++ b/common/vm/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./qemu-guest.nix + ]; +} diff --git a/common/vm/qemu-guest.nix b/common/vm/qemu-guest.nix new file mode 100644 index 0000000..65105c0 --- /dev/null +++ b/common/vm/qemu-guest.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + services.qemuGuest.enable = true; +} diff --git a/hosts/ca/configuration.nix b/hosts/ca/configuration.nix index dc73973..d20c608 100644 --- a/hosts/ca/configuration.nix +++ b/hosts/ca/configuration.nix @@ -8,6 +8,7 @@ ../template/hardware-configuration.nix ../../system + ../../common/vm ]; nixpkgs.config.allowUnfree = true; diff --git a/hosts/ha1/configuration.nix b/hosts/ha1/configuration.nix index 58a0cd3..e4d84aa 100644 --- a/hosts/ha1/configuration.nix +++ b/hosts/ha1/configuration.nix @@ -1,12 +1,17 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { - imports = - [ - ../template/hardware-configuration.nix + imports = [ + ../template/hardware-configuration.nix - ../../system - ]; + ../../system + ../../common/vm + ]; nixpkgs.config.allowUnfree = true; # Use the systemd-boot EFI boot loader. @@ -39,7 +44,10 @@ }; time.timeZone = "Europe/Oslo"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; nix.settings.tarball-ttl = 0; environment.systemPackages = with pkgs; [ vim @@ -67,4 +75,3 @@ system.stateVersion = "23.11"; # Did you read the comment? } - diff --git a/hosts/http-proxy/configuration.nix b/hosts/http-proxy/configuration.nix index 0264996..aa5b7e2 100644 --- a/hosts/http-proxy/configuration.nix +++ b/hosts/http-proxy/configuration.nix @@ -8,6 +8,7 @@ ../template/hardware-configuration.nix ../../system + ../../common/vm ]; nixpkgs.config.allowUnfree = true; diff --git a/hosts/monitoring01/configuration.nix b/hosts/monitoring01/configuration.nix index 50c5b4f..5c0a731 100644 --- a/hosts/monitoring01/configuration.nix +++ b/hosts/monitoring01/configuration.nix @@ -8,6 +8,7 @@ ../template/hardware-configuration.nix ../../system + ../../common/vm ]; nixpkgs.config.allowUnfree = true; @@ -52,6 +53,8 @@ git ]; + services.qemuGuest.enable = true; + # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; # networking.firewall.allowedUDPPorts = [ ... ]; diff --git a/hosts/ns1/configuration.nix b/hosts/ns1/configuration.nix index df07579..c56f0b0 100644 --- a/hosts/ns1/configuration.nix +++ b/hosts/ns1/configuration.nix @@ -1,14 +1,19 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { - imports = - [ - ../template/hardware-configuration.nix + imports = [ + ../template/hardware-configuration.nix - ../../system - ../../services/ns/master-authorative.nix - ../../services/ns/resolver.nix - ]; + ../../system + ../../services/ns/master-authorative.nix + ../../services/ns/resolver.nix + ../../common/vm + ]; nixpkgs.config.allowUnfree = true; # Use the systemd-boot EFI boot loader. @@ -38,7 +43,10 @@ }; time.timeZone = "Europe/Oslo"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; nix.settings.tarball-ttl = 0; environment.systemPackages = with pkgs; [ vim @@ -54,4 +62,3 @@ system.stateVersion = "23.11"; # Did you read the comment? } - diff --git a/hosts/ns2/configuration.nix b/hosts/ns2/configuration.nix index e1189b2..72bb2f5 100644 --- a/hosts/ns2/configuration.nix +++ b/hosts/ns2/configuration.nix @@ -1,14 +1,19 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { - imports = - [ - ../template/hardware-configuration.nix + imports = [ + ../template/hardware-configuration.nix - ../../system - ../../services/ns/secondary-authorative.nix - ../../services/ns/resolver.nix - ]; + ../../system + ../../services/ns/secondary-authorative.nix + ../../services/ns/resolver.nix + ../../common/vm + ]; nixpkgs.config.allowUnfree = true; # Use the systemd-boot EFI boot loader. @@ -38,7 +43,10 @@ }; time.timeZone = "Europe/Oslo"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; environment.systemPackages = with pkgs; [ vim wget @@ -53,4 +61,3 @@ system.stateVersion = "23.11"; # Did you read the comment? } - diff --git a/system/monitoring/metrics.nix b/system/monitoring/metrics.nix index 61f8d91..b65837f 100644 --- a/system/monitoring/metrics.nix +++ b/system/monitoring/metrics.nix @@ -5,6 +5,8 @@ enabledCollectors = [ "systemd" "logind" + "cgroups" + "processes" ]; }; }