add the checkmk agent and config

This commit is contained in:
Daniel Frank 2024-08-21 01:16:00 +02:00
parent 916f394cdf
commit 05459a50e1
Signed by: tokudan
GPG key ID: 063CCCAD04182D32
6 changed files with 2348 additions and 0 deletions

22
checkmk-agent.nix Normal file
View file

@ -0,0 +1,22 @@
{ lib, pkgs, ... }:
let
agentcmd = "${ (pkgs.callPackage ./checkmk-agent/default.nix { }) }/bin/check_mk_agent.sshwrapper";
in
{
users.users.mon = {
isNormalUser = true;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [
''restrict,command="${ agentcmd }" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGHkivi9Ye/Uj4ZQxrEfarSaz0iLF/XXhY/crNsLoDMu checkmk''
];
};
security.sudo.extraRules = [ {
users = [ "mon" ];
commands = [ {
command = agentcmd;
options = [ "NOPASSWD" ];
} ];
}
];
}

BIN
checkmk-agent/agent.tar.gz Normal file

Binary file not shown.

26
checkmk-agent/default.nix Normal file
View file

@ -0,0 +1,26 @@
{ stdenv, lib, makeWrapper }:
stdenv.mkDerivation rec {
name = "checkmk-agent";
src = ./agent.tar.gz;
phases = [ "unpackPhase" "installPhase" "fixupPhase" "wrapPhase" ];
buildInputs = [ ];
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
mkdir -p $out/bin
install -m 0755 check_mk_agent.linux $out/bin/check_mk_agent
substitute sshwrapper $out/bin/check_mk_agent.sshwrapper \
--replace SUDOCOMMAND "$out/bin/check_mk_agent"
chmod 0755 $out/bin/check_mk_agent.sshwrapper
'';
wrapPhase = ''
wrapProgram $out/bin/check_mk_agent --suffix PATH : /run/current-system/sw/bin
'';
meta = with lib; {
description = "checkmk-agent";
platforms = platforms.all;
};
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# The agent does not need stdin
exec </dev/null
exec sudo --non-interactive -- SUDOCOMMAND

View file

@ -9,6 +9,7 @@
[
./hardware-configuration.nix
./acme.nix
./checkmk-agent.nix
./sshusers.nix
./mailserver.nix
./borgbackup.nix