nixos: add comin, hosts pull their configuration from main
All checks were successful
nixos / nixos (push) Successful in 3m22s
All checks were successful
nixos / nixos (push) Successful in 3m22s
Each host runs comin, which polls main of this repository every minute, builds nixosConfigurations.<hostname> on the host and switches to it. A branch testing-<hostname> on top of main is applied with `test` to that host alone. Prometheus scrapes comin over the private network, and a failing fetch, evaluation, build or switch alerts after 15 minutes. CI still deploys this commit, which starts comin; the CI deploy job and its SSH key go in the next commit, once comin runs on both hosts. Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
2635b887c7
commit
9290a4e181
5 changed files with 115 additions and 0 deletions
60
nixos/flake.lock
generated
60
nixos/flake.lock
generated
|
|
@ -1,5 +1,44 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"comin": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"treefmt-nix": "treefmt-nix"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1784448272,
|
||||||
|
"narHash": "sha256-zkI/QkILbWpjhBOzF7K/kCVsJfCkBbMO96d5B0abfE4=",
|
||||||
|
"owner": "nlewo",
|
||||||
|
"repo": "comin",
|
||||||
|
"rev": "ed92afc48978fb15a2535ebd5c5f63b3010e3b78",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nlewo",
|
||||||
|
"ref": "v0.14.0",
|
||||||
|
"repo": "comin",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1765121682,
|
||||||
|
"narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794552581,
|
"lastModified": 1794552581,
|
||||||
|
|
@ -34,6 +73,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"comin": "comin",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
"sops-nix": "sops-nix"
|
"sops-nix": "sops-nix"
|
||||||
|
|
@ -58,6 +98,26 @@
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1770228511,
|
||||||
|
"narHash": "sha256-wQ6NJSuFqAEmIg2VMnLdCnUc0b7vslUohqqGGD+Fyxk=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "337a4fe074be1042a35086f15481d763b8ddc0e7",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@
|
||||||
url = "github:Mic92/sops-nix";
|
url = "github:Mic92/sops-nix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
# The deploy agent (modules/comin.nix)
|
||||||
|
comin = {
|
||||||
|
url = "github:nlewo/comin/v0.14.0";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
|
|
@ -16,6 +22,7 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
nixpkgs-unstable,
|
nixpkgs-unstable,
|
||||||
sops-nix,
|
sops-nix,
|
||||||
|
comin,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -26,6 +33,7 @@
|
||||||
specialArgs.unstable = nixpkgs-unstable.legacyPackages.x86_64-linux;
|
specialArgs.unstable = nixpkgs-unstable.legacyPackages.x86_64-linux;
|
||||||
modules = [
|
modules = [
|
||||||
sops-nix.nixosModules.sops
|
sops-nix.nixosModules.sops
|
||||||
|
comin.nixosModules.comin
|
||||||
./modules/hetzner.nix
|
./modules/hetzner.nix
|
||||||
./modules/base.nix
|
./modules/base.nix
|
||||||
./modules/shell.nix
|
./modules/shell.nix
|
||||||
|
|
@ -33,6 +41,7 @@
|
||||||
./modules/wireguard.nix
|
./modules/wireguard.nix
|
||||||
./modules/alert.nix
|
./modules/alert.nix
|
||||||
./modules/backup.nix
|
./modules/backup.nix
|
||||||
|
./modules/comin.nix
|
||||||
./modules/monitoring-agent.nix
|
./modules/monitoring-agent.nix
|
||||||
]
|
]
|
||||||
++ modules;
|
++ modules;
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,23 @@ groups:
|
||||||
for: 6h
|
for: 6h
|
||||||
labels: { severity: warning }
|
labels: { severity: warning }
|
||||||
annotations: { summary: "ejabberd's certificate expires {{ $values.A.Value | printf \"%.0f\" }} days before the one Traefik holds: the push or the reload failed" }
|
annotations: { summary: "ejabberd's certificate expires {{ $values.A.Value | printf \"%.0f\" }} days before the one Traefik holds: the push or the reload failed" }
|
||||||
|
- uid: deploy-failed
|
||||||
|
title: "Deploy failing"
|
||||||
|
condition: C
|
||||||
|
data:
|
||||||
|
- refId: A
|
||||||
|
relativeTimeRange: { from: 900, to: 0 }
|
||||||
|
datasourceUid: prometheus
|
||||||
|
# comin: fetching main, evaluating, building or switching
|
||||||
|
model: { refId: A, expr: "max by (host, __name__) ({__name__=~\"comin_last_(fetch|eval|build|deployment)_failed\"})", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
||||||
|
- refId: C
|
||||||
|
datasourceUid: __expr__
|
||||||
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
||||||
|
noDataState: OK
|
||||||
|
execErrState: Error
|
||||||
|
for: 15m
|
||||||
|
labels: { severity: warning }
|
||||||
|
annotations: { summary: "{{ $labels.host }}: {{ $labels.__name__ }} (comin status on the host)" }
|
||||||
- uid: replica-stale
|
- uid: replica-stale
|
||||||
title: "Bucket replica stale"
|
title: "Bucket replica stale"
|
||||||
condition: C
|
condition: C
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ in
|
||||||
job_name = "alloy";
|
job_name = "alloy";
|
||||||
static_configs = perHost 12345;
|
static_configs = perHost 12345;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
job_name = "comin";
|
||||||
|
static_configs = perHost 4243;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
job_name = "traefik";
|
job_name = "traefik";
|
||||||
static_configs = [
|
static_configs = [
|
||||||
|
|
|
||||||
25
nixos/modules/comin.nix
Normal file
25
nixos/modules/comin.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Deploys: each host pulls main of this repository and switches to
|
||||||
|
# nixosConfigurations.<its hostname> (comin, polling every minute). CI only
|
||||||
|
# evaluates. A branch testing-<hostname> on top of main is applied with
|
||||||
|
# `test` (not the boot default) to that host alone: try a change there,
|
||||||
|
# then merge it. `comin status` on the host shows what it is doing.
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
services.comin = {
|
||||||
|
enable = true;
|
||||||
|
remotes = [
|
||||||
|
{
|
||||||
|
name = "origin";
|
||||||
|
url = "https://git.asxp.io/asxpi/iac.git";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
repositorySubdir = "nixos";
|
||||||
|
# Prometheus on ops scrapes it over the private network
|
||||||
|
exporter = {
|
||||||
|
listen_address = config.asxpio.privateIPv4;
|
||||||
|
port = 4243;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
asxpio.security.ports = [ "tcp/4243/comin" ];
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue