@cryptotaxi247 / infra / commits / 16bed637

hydra-packet-import: init service

Graham Christensen committed Apr 26, 2019 at 16:55 UTC 16bed6376d67ba2360e4412838e59cf2e531703c
2 files changed +45
delft/chef.nix
+1
@@ -9,6 +9,7 @@
9 ./fstrim.nix
10 ./provisioner.nix
11 ../modules/wireguard.nix
12 + ./packet-importer.nix
13 ];
14
15 deployment.targetEnv = "hetzner";
delft/packet-importer.nix new
+44
@@ -0,0 +1,44 @@
1 +{ config, lib, pkgs, ... }:
2 +let
3 + importer = pkgs.callPackage ../hydra-packet-importer { };
4 +in
5 +{
6 + deployment.keys."hydra-packet-import.json" = {
7 + keyFile = ../hydra-packet-import.json;
8 + user = "hydra-packet";
9 + };
10 +
11 + users.extraUsers.hydra-packet = {
12 + description = "Hydra Packet Machine Importer";
13 + group = "hydra";
14 + };
15 +
16 + systemd.tmpfiles.rules = [
17 + "d /var/lib/hydra/packet-import 0755 hydra-packet hydra -"
18 + "f /var/lib/hydra/packet-import/machines 0644 hydra-packet hydra -"
19 + ];
20 +
21 + services.hydra-dev.buildMachinesFiles = [
22 + "/var/lib/hydra/packet-import/machines"
23 + ];
24 +
25 + systemd.services.hydra-packet-import = {
26 + path = with pkgs; [ openssh moreutils ];
27 + script = "${importer}/bin/hydra-packet-importer /run/keys/hydra-packet-import.json | sponge /var/lib/hydra/packet-import/machines";
28 + serviceConfig = {
29 + User = "hydra-packet";
30 + Group = "keys";
31 + SupplementaryGroups = [ "hydra" "keys" ];
32 + Type = "oneshot";
33 + };
34 + };
35 +
36 + systemd.timers.hydra-packet-import = {
37 + enable = true;
38 + description = "Update the list of Hydra machines from Packet.net";
39 + wantedBy = [ "timers.target" ];
40 + timerConfig = {
41 + OnCalendar = "*:0/5";
42 + };
43 + };
44 +}