From e2bd1439e19dea2cb5b2d3c531b1e3107a0e20a1 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 3 Mar 2022 01:01:03 +0100 Subject: [PATCH] clusterfuck --- nix/nixos-module/server/defaults.nix | 10 +++++----- nix/nixos-module/server/lxc-containers.nix | 10 +--------- nix/nixos-module/server/network.nix | 8 ++++++++ nix/nixos-module/server/qemu.nix | 7 ++++++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/nix/nixos-module/server/defaults.nix b/nix/nixos-module/server/defaults.nix index 64e7890..5310c6e 100644 --- a/nix/nixos-module/server/defaults.nix +++ b/nix/nixos-module/server/defaults.nix @@ -18,18 +18,18 @@ resources = builtins.toFile "cib-resources.xml" '' ${lib.concatMapStrings (container: '' - + - - - + + + '') containers} ''; cib-set-resources = writeScriptBin "cib-set-resources" '' - !# ${runtimeShell} -e + #! ${runtimeShell} -e crm_attribute -t crm_config -n stonith-enabled -v false cibadmin --replace --scope resources --xml-file ${resources} diff --git a/nix/nixos-module/server/lxc-containers.nix b/nix/nixos-module/server/lxc-containers.nix index d6d8f42..88edf36 100644 --- a/nix/nixos-module/server/lxc-containers.nix +++ b/nix/nixos-module/server/lxc-containers.nix @@ -131,8 +131,7 @@ let systemctl restart lxc@$c ) else - echo Starting $c - systemctl start lxc@$c + echo Ignoring not-running container $c fi done set -e @@ -236,11 +235,4 @@ in RestartSec = "1s"; }; }; - - # Starts all the containers after boot - systemd.targets.lxc-containers = { - wantedBy = [ "multi-user.target" ]; - wants = map (ctName: "lxc@${ctName}.service") - (builtins.attrNames containers); - }; } diff --git a/nix/nixos-module/server/network.nix b/nix/nixos-module/server/network.nix index 0bdd637..343a28b 100644 --- a/nix/nixos-module/server/network.nix +++ b/nix/nixos-module/server/network.nix @@ -85,6 +85,14 @@ in EmitLLDP = true; }; }; + "00-qemu-tap" = { + # physical ethernet ports + matchConfig.MACAddress = { + server1 = "00:02:23:de:ad:41"; + server2 = "00:02:23:de:ad:42"; + }.${hostName}; + networkConfig.Bond = "bond0"; + }; bond0 = { DHCP = "no"; matchConfig.Name = "bond0"; diff --git a/nix/nixos-module/server/qemu.nix b/nix/nixos-module/server/qemu.nix index d793b17..8aed37c 100644 --- a/nix/nixos-module/server/qemu.nix +++ b/nix/nixos-module/server/qemu.nix @@ -1,5 +1,5 @@ # Options for running under qemu (vm-packages) -{ inputs, lib, options, ... }: +{ inputs, config, lib, options, ... }: { # Get internet from qemu user networking systemd.network = lib.optionalAttrs (options.virtualisation ? qemu) { @@ -23,6 +23,11 @@ # keep the store paths built inside the VM across reboots writableStoreUseTmpfs = false; qemu.options = [ "-enable-kvm" ]; + qemu.networkingOptions = [ + # Useful for cluster dev + "-device" "virtio-net-pci,id=bond,netdev=bond,mac=${config.systemd.network.networks."00-qemu-tap".matchConfig.MACAddress}" + "-netdev" "tap,id=bond,ifname=${config.networking.hostName},script=no,downscript=no" + ]; }; # Let the nix registry point to the state of your local checkout