Skip to content

Commit

Permalink
Add Tailscale exit node profile (#21)
Browse files Browse the repository at this point in the history
* Add Tailscale exit node profile

* Format files
  • Loading branch information
ethnt authored Dec 26, 2023
1 parent d0a3b14 commit c54109b
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ repl:

format:
nix fmt

alias fmt := format
7 changes: 7 additions & 0 deletions deploy/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions deploy/configuration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ provider "aws" {

provider "proxmox" {
alias = "anise"
pm_api_url = "https://192.168.10.10:8006/api2/json"
pm_api_url = "https://anise:8006/api2/json"
pm_api_token_id = data.sops_file.secrets.data["ANISE_PM_API_TOKEN_ID"]
pm_api_token_secret = data.sops_file.secrets.data["ANISE_PM_API_TOKEN_SECRET"]
}

provider "proxmox" {
alias = "basil"
pm_api_url = "https://192.168.10.20:8006/api2/json"
pm_api_url = "https://basil:8006/api2/json"
pm_api_token_id = data.sops_file.secrets.data["BASIL_PM_API_TOKEN_ID"]
pm_api_token_secret = data.sops_file.secrets.data["BASIL_PM_API_TOKEN_SECRET"]
}

provider "proxmox" {
alias = "cardamom"
pm_api_url = "https://192.168.10.30:8006/api2/json"
pm_api_url = "https://cardamom:8006/api2/json"
pm_api_token_id = data.sops_file.secrets.data["CARDAMOM_PM_API_TOKEN_ID"]
pm_api_token_secret = data.sops_file.secrets.data["CARDAMOM_PM_API_TOKEN_SECRET"]
}
38 changes: 36 additions & 2 deletions deploy/vms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ resource "proxmox_vm_qemu" "htpc" {
iso = "local:iso/latest-nixos-minimal-x86_64-linux.iso"
vmid = 101
cpu = "host,flags=+pcid"
memory = 65536
memory = 32768
balloon = 0
sockets = 1
cores = 16
Expand All @@ -67,7 +67,6 @@ resource "proxmox_vm_qemu" "htpc" {

bios = "seabios"


network {
model = "virtio"
bridge = "vmbr0"
Expand All @@ -92,6 +91,41 @@ resource "proxmox_vm_qemu" "htpc" {
}
}

resource "proxmox_vm_qemu" "builder" {
provider = proxmox.basil

name = "builder"
target_node = "basil"
iso = "omnibus:iso/latest-nixos-minimal-x86_64-linux.iso"
vmid = 102
cpu = "host"
memory = 32768
balloon = 0
sockets = 1
cores = 8
qemu_os = "other"
scsihw = "virtio-scsi-single"
# boot = "order=scsi0"

onboot = true
agent = 1

bios = "seabios"

network {
model = "virtio"
bridge = "vmbr0"
}

disk {
type = "scsi"
size = "128G"
storage = "local-zfs"
discard = "on"
format = "raw"
}
}

resource "proxmox_vm_qemu" "matrix" {
provider = proxmox.cardamom

Expand Down
97 changes: 97 additions & 0 deletions hosts/builder/disk-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
_:
let disks = { scsi = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0"; };
in {
disko.devices = {
disk = {
root = {
type = "disk";
device = disks.scsi;
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02";
};

ESP = {
size = "1G";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};

zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};

zpool = {
zroot = {
type = "zpool";

options = {
ashift = "12";
autotrim = "on";
};

rootFsOptions = {
acltype = "posixacl";
compression = "lz4";
dnodesize = "auto";
normalization = "formD";
relatime = "on";
xattr = "sa";
mountpoint = "none";
};

postCreateHook = ''
zfs snapshot zroot/root@empty
zfs mount
'';

datasets = {
"root" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/";
};

"nix" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/nix";
};

"var" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/var";
};

"persist" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/persist";
};

"home" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/home";
};
};
};
};
};
}
18 changes: 18 additions & 0 deletions hosts/builder/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
boot.initrd.availableKernelModules = [
"ahci"
"ehci_pci"
"nvme"
"sd_mod"
"sr_mod"
"uhci_hcd"
"virtio_pci"
"virtio_scsi"
];

boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];

swapDevices = [ ];
}
15 changes: 8 additions & 7 deletions hosts/controller/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{ suites, profiles, ... }: {
imports = with suites;
core ++ [
profiles.power.server.apc
profiles.networking.unifi
profiles.networking.blocky
profiles.databases.postgresql.blocky
profiles.databases.postgresql.default
profiles.databases.redis.blocky
profiles.filesystems.hybrid-boot
profiles.filesystems.zfs
profiles.hardware.intel
profiles.hardware.hidpi
profiles.hardware.intel
profiles.hardware.ssd
profiles.hardware.thermald
profiles.databases.redis.blocky
profiles.databases.postgresql.default
profiles.databases.postgresql.blocky
profiles.networking.blocky
profiles.networking.tailscale.exit-node
profiles.networking.unifi
profiles.power.server.apc
profiles.telemetry.prometheus-nut-exporter
profiles.telemetry.prometheus-smokeping-exporter
] ++ [ ./disk-config.nix ./hardware-configuration.nix ];
Expand Down
4 changes: 1 addition & 3 deletions hosts/omnibus/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@
};

programs.fish.shellAliases.iotop = ''
bash -c "sudo sysctl kernel.task_delayacct=1 && sudo ${
pkgs.lib.getExe pkgs.iotop
} ; sudo sysctl kernel.task_delayacct=0"
bash -c "sudo sysctl kernel.task_delayacct=1 && sudo ${pkgs.iotop}/bin/iotop ; sudo sysctl kernel.task_delayacct=0"
'';

system.stateVersion = "23.11";
Expand Down
9 changes: 9 additions & 0 deletions modules/profiles/networking/tailscale/exit-node.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ lib, ... }: {
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
};

services.tailscale.extraUpFlags =
lib.mkAfter [ "--advertise-exit-node" "--advertise-routes=192.168.0.0/24" ];
}

0 comments on commit c54109b

Please sign in to comment.