diff options
author | lassulus <lassulus@lassul.us> | 2019-06-15 00:53:40 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2019-06-15 00:53:40 +0200 |
commit | cb7fcd8efa81950c97da531757aabdfecb28f2f1 (patch) | |
tree | e28d793d8291348ccfa02d79003e525fafd4d8cf /krebs/2configs/shack/netbox.nix | |
parent | ec93824f05c8f89e738831c2c059e934cbffafb8 (diff) | |
parent | df9b3fa1be5eb3e812f605ea78ac3f7363b52211 (diff) |
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'krebs/2configs/shack/netbox.nix')
-rw-r--r-- | krebs/2configs/shack/netbox.nix | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/krebs/2configs/shack/netbox.nix b/krebs/2configs/shack/netbox.nix new file mode 100644 index 000000000..4fb5a7dbc --- /dev/null +++ b/krebs/2configs/shack/netbox.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: +{ + environment.systemPackages = [ pkgs.docker-compose ]; + virtualisation.docker.enable = true; + services.nginx = { + enable = true; + virtualHosts."netbox.shack".locations."/".proxyPass = "http://localhost:18080"; + }; + # we store the netbox config there: + # state = [ "/var/lib/netbox" ]; + systemd.services.backup-netbox = { + after = [ "netbox-docker-compose.service" ]; + startAt = "daily"; + path = with pkgs; [ docker-compose docker gzip coreutils ]; + script = '' + cd /var/lib/netbox + mkdir -p backup + docker-compose exec -T -upostgres postgres pg_dumpall \ + | gzip > backup/netdata_$(date -Iseconds).dump.gz + ''; + }; + + systemd.services.netbox-docker-compose = { + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" "docker.service" ]; + environment.VERSION = "v2.5.13"; + serviceConfig = { + WorkingDirectory = "/var/lib/netbox"; + # TODO: grep -q NAPALM_SECRET env/netbox.env + # TODO: grep -q NAPALM_SECRET netbox-netprod-importer/switches.yml + ExecStartPre = "${pkgs.docker-compose}/bin/docker-compose pull"; + ExecStart = "${pkgs.docker-compose}/bin/docker-compose up"; + Restart = "always"; + RestartSec = "10"; + StartLimitIntervalSec = 60; + StartLimitBurst = 3; + }; + }; +} |