From 4b8353c011cc9e2ea2d236e2d3b7db577a5ebd64 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 6 Mar 2021 02:57:35 +0100 Subject: [PATCH] scrape: migrate from krops to flakes --- flake.lock | 8 ++--- flake.nix | 13 +++++++++ host-registry.nix | 4 +++ .../scrape/{configuration.nix => default.nix} | 29 +++++-------------- krops.nix | 1 - 5 files changed, 29 insertions(+), 26 deletions(-) rename hosts/containers/scrape/{configuration.nix => default.nix} (79%) diff --git a/flake.lock b/flake.lock index ac7daee3..0fccc05c 100644 --- a/flake.lock +++ b/flake.lock @@ -40,11 +40,11 @@ }, "secrets": { "locked": { - "lastModified": 1614993322, - "narHash": "sha256-JcC7oPS8qCmk+abBGUzNvgV2B9XACcNSjc0pfX0ldoA=", + "lastModified": 1614994700, + "narHash": "sha256-2QCQB+w1teVZT83kfDifE1uKvFgm1wEL+3OHYG2+gFI=", "ref": "master", - "rev": "30c7719adc2615e87e3b38596384ecec24347883", - "revCount": 81, + "rev": "abe64361305019ae7664d03fc29e1ac9faae2222", + "revCount": 83, "type": "git", "url": "ssh://git@gitea.c3d2.de:2222/c3d2-admins/secrets.git" }, diff --git a/flake.nix b/flake.nix index 49fb9c71..1a6ce343 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,8 @@ freifunk-nixos-rebuild = mkDeploy "freifunk" "freifunk.core.zentralwerk.org"; matemat-nixos-rebuild = mkDeploy "matemat" hostRegistry.hosts.matemat.ip4; + + scrape-nixos-rebuild = mkDeploy "scrape" hostRegistry.hosts.scrape.ip4; }); nixosConfigurations = let @@ -147,6 +149,17 @@ system = "x86_64-linux"; }; + scrape = nixosSystem' { + modules = [ + ./lib/lxc-container.nix + ./hosts/containers/scrape + ({ ... }: { + nixpkgs.overlays = [ secrets.overlays.scrape ]; + }) + ]; + system = "x86_64-linux"; + }; + }; nixosModules.c3d2 = import ./lib; diff --git a/host-registry.nix b/host-registry.nix index e4ae3825..c98af2c5 100644 --- a/host-registry.nix +++ b/host-registry.nix @@ -81,6 +81,10 @@ rec { ip4 = "172.22.99.133"; ip6 = "2a02:8106:208:5201:f82b:1bff:fedc:8572"; }; + scrape = { + ip4 = "172.20.73.32"; + ip6 = "2a02:8106:208:5282:e073:50ff:fef5:eb6e"; + }; }; hqGlobal = builtins.attrNames hosts; diff --git a/hosts/containers/scrape/configuration.nix b/hosts/containers/scrape/default.nix similarity index 79% rename from hosts/containers/scrape/configuration.nix rename to hosts/containers/scrape/default.nix index b228ce12..1831be6b 100644 --- a/hosts/containers/scrape/configuration.nix +++ b/hosts/containers/scrape/default.nix @@ -3,25 +3,13 @@ let freifunkNodes = { "1139" = "10.200.4.120"; - "1487" = "10.200.5.213"; "1884" = "10.200.7.100"; "1891" = "10.200.7.107"; - "1768" = "10.200.6.239"; - "1176" = "10.200.7.80"; "1099" = "10.200.4.80"; + "1864" = "10.200.7.80"; }; in { - imports = [ - (modulesPath + "/profiles/minimal.nix") - ../../../lib - ../../../lib/lxc-container.nix - ../../../lib/shared.nix - ]; - - c3d2 = { - isInHq = false; - hq.interface = "eth0"; - }; + c3d2.isInHq = false; networking.hostName = "scrape"; networking.interfaces.eth0.ipv4.addresses = [{ @@ -35,16 +23,15 @@ in { environment.systemPackages = [ pkgs.git ]; systemd.services = let - scrapers = import (builtins.fetchGit { + scrapers = import (pkgs.fetchgit { url = "https://gitea.c3d2.de/astro/scrapers.git"; + rev = "77c864b4d7e1ef4075ed115b036791c75176bef7"; + sha256 = "1rj4dyn89zqyfaiv2ffi6g4x86l2xfgybyy5hlvxzgcabwaxdjyh"; }) { inherit pkgs; }; makeService = { script, host, user ? "", password ? "" }: { script = "${scrapers.${script}}/bin/${script} ${host} ${user} ${password}"; }; - xeriLogin = import ; - fhemLogin = import ; - matematLogin = import ; makeNodeScraper = nodeId: { name = "scrape-node${nodeId}"; value = makeService { @@ -56,7 +43,7 @@ in { scrape-xeri = makeService { script = "xerox"; host = "xeri.hq.c3d2.de"; - inherit (xeriLogin) user password; + inherit (pkgs.scrape-xeri-login) user password; }; scrape-roxi = makeService { script = "xerox"; @@ -65,12 +52,12 @@ in { scrape-fhem = makeService { script = "fhem"; host = "fhem.hq.c3d2.de"; - inherit (fhemLogin) user password; + inherit (pkgs.scrape-fhem-login) user password; }; scrape-matemat = makeService { script = "matemat"; host = "matemat.hq.c3d2.de"; - inherit (matematLogin) user password; + inherit (pkgs.scrape-matemat-login) user password; }; } // builtins.listToAttrs (map makeNodeScraper (builtins.attrNames freifunkNodes)); diff --git a/krops.nix b/krops.nix index 21f49492..7f230b1a 100644 --- a/krops.nix +++ b/krops.nix @@ -22,7 +22,6 @@ let target = "root@${host}"; }; in { - scrape = deployContainer "scrape" "172.20.73.32"; ledstripes = deployContainer "ledstripes" "172.22.99.168"; kibana = deployContainer "kibana" "172.20.73.44"; }