diff --git a/flake.nix b/flake.nix index 630de2c..f270ec4 100644 --- a/flake.nix +++ b/flake.nix @@ -24,13 +24,14 @@ mkConfig = { hostname, profile ? hostname, lxc ? true, ... }: { "${profile}" = lib.nixosSystem { inherit system; - modules = - [ ./nixos/common "${./.}/nixos/hosts/${profile}/configuration.nix" ] - ++ (if lxc then [ - "${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix" - ./nixos/common/generic-lxc.nix - ] else - [ ./nixos/common/generic-vm.nix ]); + modules = [ + ./nixos/common + "${./.}/nixos/hosts/${profile}/configuration.nix" + ] ++ (if lxc then [ + "${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix" + ./nixos/common/generic-lxc.nix + ] else + [ ./nixos/common/generic-vm.nix ]); specialArgs = { inherit hosts inputs; }; }; }; @@ -75,19 +76,20 @@ lib.foldr (el: acc: acc // mkConfig el) { } nixHosts; deploy.nodes = lib.foldr (el: acc: acc // mkDeploy el) { } nixHosts; - apps.x86_64-linux.vault-push-approles = { - type = "app"; - program = "${pkgs.vault-push-approles self}/bin/vault-push-approles"; - }; - apps.x86_64-linux.vault-push-approle-envs = { - type = "app"; - program = - "${pkgs.vault-push-approle-envs self}/bin/vault-push-approle-envs"; - }; - - apps.x86_64-linux.tfvars = { - type = "app"; - program = "${genTFVars}/bin/gen-tf-vars"; + apps.${system} = { + vault-push-approles = { + type = "app"; + program = "${pkgs.vault-push-approles self}/bin/vault-push-approles"; + }; + vault-push-approle-envs = { + type = "app"; + program = + "${pkgs.vault-push-approle-envs self}/bin/vault-push-approle-envs"; + }; + tfvars = { + type = "app"; + program = "${genTFVars}/bin/gen-tf-vars"; + }; }; # Use by running `nix develop` diff --git a/hosts.nix b/hosts.nix index 5db11cf..8b12632 100644 --- a/hosts.nix +++ b/hosts.nix @@ -84,8 +84,8 @@ } { hostname = "victoriametrics"; - ip = "10.42.42.18"; - mac = "A9:E4:AA:7C:7E:EB"; + ip = "10.42.42.19"; + mac = "9E:91:61:35:84:1F"; } { hostname = "nuc"; diff --git a/nixos/hosts/minio/configuration.nix b/nixos/hosts/minio/configuration.nix index 0b75886..35df691 100644 --- a/nixos/hosts/minio/configuration.nix +++ b/nixos/hosts/minio/configuration.nix @@ -3,10 +3,8 @@ # and in the NixOS manual (accessible by running ‘nixos-help’). { config, pkgs, ... }: -let -vs = config.vault-secrets.secrets; -in -{ +let vs = config.vault-secrets.secrets; +in { imports = [ ]; networking.hostName = "minio"; diff --git a/nixos/hosts/victoriametrics/configuration.nix b/nixos/hosts/victoriametrics/configuration.nix new file mode 100644 index 0000000..6d4b4d2 --- /dev/null +++ b/nixos/hosts/victoriametrics/configuration.nix @@ -0,0 +1,46 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: +let + vmPort = 8428; + vs = config.vault-secrets.secrets; +in { + imports = [ ]; + + networking.hostName = "victoriametrics"; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.11"; # Did you read the comment? + + # Additional packages + environment.systemPackages = with pkgs; [ ]; + + networking.firewall.allowedTCPPorts = [ vmPort config.services.grafana.port ]; + networking.firewall.allowedUDPPorts = [ vmPort ]; + + services.victoriametrics = { + enable = true; + listenAddress = ":${toString vmPort}"; + # Data Retention period in months + retentionPeriod = 12; + }; + + vault-secrets.secrets.grafana = { + user = "grafana"; + group = "grafana"; + }; + + services.grafana = { + enable = true; + addr = "0.0.0.0"; + port = 2342; + security.adminPasswordFile = "${vs.grafana}/password"; + }; +} diff --git a/terraform/hosts.auto.tfvars.json b/terraform/hosts.auto.tfvars.json index 8ae9e26..6ffa1bf 100644 --- a/terraform/hosts.auto.tfvars.json +++ b/terraform/hosts.auto.tfvars.json @@ -49,7 +49,7 @@ "mac": "16:2B:87:55:0C:0C" }, "victoriametrics": { - "mac": "A9:E4:AA:7C:7E:EB" + "mac": "9E:91:61:35:84:1F" } } } diff --git a/terraform/proxmox_lxc.tf b/terraform/proxmox_lxc.tf index afde302..6b16501 100644 --- a/terraform/proxmox_lxc.tf +++ b/terraform/proxmox_lxc.tf @@ -253,25 +253,25 @@ resource "proxmox_lxc" "dhcp" { } } -resource "proxmox_lxc" "victoriametrics" { - target_node = "nuc" - hostname = "victoriametrics" - vmid = 113 - clone = 108 - unprivileged = true - onboot = true - cores = 1 +# resource "proxmox_lxc" "victoriametrics" { +# target_node = "nuc" +# hostname = "victoriametrics" +# vmid = 113 +# clone = 108 +# unprivileged = true +# onboot = true +# cores = 1 - memory = 512 +# memory = 512 - rootfs { - storage = "local-zfs" - size = "25G" - } +# rootfs { +# storage = "local-zfs" +# size = "25G" +# } - network { - name = "eth0" - bridge = "vmbr0" - hwaddr = var.hosts.victoriametrics.mac - } -} +# network { +# name = "eth0" +# bridge = "vmbr0" +# hwaddr = var.hosts.victoriametrics.mac +# } +# }