This commit is contained in:
parent
fadd0c41d4
commit
d0b752983a
13 changed files with 0 additions and 347 deletions
|
@ -1,44 +0,0 @@
|
|||
# This file is maintained automatically by "tofu init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.opentofu.org/digitalocean/digitalocean" {
|
||||
version = "2.40.0"
|
||||
constraints = "~> 2.0"
|
||||
hashes = [
|
||||
"h1:Y7VkuuqOBgv+1jgL/4Hi247K2BskXwXtR/Uk9ssK/e4=",
|
||||
"zh:00235830abae70642ebefc4d9c00e5eb978e28b74abc6b34f16b078f242aa217",
|
||||
"zh:09d77785f768bd568f85a121d3d79316083befe903ce4ccd5567689a23236fb0",
|
||||
"zh:0c9c4e19b411702d316a6bd044903e2ec506a69d38495ed32cc31e3f3f26acae",
|
||||
"zh:12b34c88faad5b6149e9a3ad1396680588e1bae263b20d6b19835460f111c190",
|
||||
"zh:15f041fc57ea46673a828919efe2ef3f05f7c4b863b7d7881336b93e92bd1159",
|
||||
"zh:45e01972de2fab1687a09ea8fb3e4519be11c93ef93a63f28665630850858a20",
|
||||
"zh:4e18bf5c1d2ec1ec6b6a9f4b58045309006f510edf770168fc18e273e6a09289",
|
||||
"zh:575528b7e36e3489d2309e0c6cb9bd9952595cac5459b914f2d2827de1a1e4fc",
|
||||
"zh:67462192212f810875d556462c79f574a8f5713b7a869ba4fce25953bfcf2dd2",
|
||||
"zh:7024637b31e8276b653265fdf3f479220182edde4b300b034562b4c287faefa5",
|
||||
"zh:a7904721b2680be8330dde98dd826be15c67eb274da7876f042cbcd6592ac970",
|
||||
"zh:b225d4b67037a19392b0ab00d1f5fc9e729db4dfc32d18d4b36225693270ef52",
|
||||
"zh:bd1e8768819d6113b2ec16f939196a1f2ae6d2803824fde463a20d06e071b212",
|
||||
"zh:c5da40dc0749548ee2e1943776fb41b952c994e50bbc404251df20a81f730242",
|
||||
"zh:dabc3387392aaba297739e1e97fadf059258fc3efb4dff2f499dbc407b6e088d",
|
||||
"zh:f42137cf424c3e7c9c935b3f73618e51096bd0367a8d364073e2d70588d2cbf2",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.opentofu.org/hashicorp/dns" {
|
||||
version = "3.4.1"
|
||||
constraints = "~> 3.4.1"
|
||||
hashes = [
|
||||
"h1:6Tb2wZRxfKunvjLw47ihfkaoARWIQrJd+WCOXkx0hg4=",
|
||||
"zh:53f46f16fc3b25d9bdce61d7cc9a67cea9c67ea5347fcde35833451d5011f1c4",
|
||||
"zh:662669802c99c7e698ca52e7a32afc19acf66d97bbc05f5effacdf0fe471848f",
|
||||
"zh:8289aee49df8a0cb2fcdfded575e68df1721fc3e6ce75555def499d31b7e910d",
|
||||
"zh:90aa9b049d19137ed15ea3f88238824e1fde7d1a806378cb97520391e169a96d",
|
||||
"zh:9e5795e10d65927ba689cfabc06b72085055543342d1db26ef5963ae5ab5d64a",
|
||||
"zh:9f39b6e0ca35cf2405fe4e13af8a405cf9b0b0c34b6b06ad36f319631405a3aa",
|
||||
"zh:c37a2c140c95b3eaa9d0aeb79496b220ba1a0456d01a77fcc68bd565bee7edd5",
|
||||
"zh:cd40d356c5382f0b868df2d8539f95031e3cf0c210053674ec4c7cd20c73b82a",
|
||||
"zh:fde59f09e4e62fc84012fff8493bc64eac287a0245e1c8abf29b0138d3018dfb",
|
||||
"zh:ffee5b54936bd43247e9316de0ecc0dde36556a2cd50f090d7f6443a3f689b95",
|
||||
]
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
locals {
|
||||
locations = {
|
||||
DE = ["46.4.88.62", "2a01:4f8:202:2395::"]
|
||||
SI = ["93.103.125.118", "2a01:261:455:6c00:21e:6ff:fe45:c34"]
|
||||
}
|
||||
}
|
||||
|
||||
data "digitalocean_domain" "ingress" {
|
||||
name = "ingress.tjo.cloud"
|
||||
}
|
||||
|
||||
resource "digitalocean_record" "locations" {
|
||||
for_each = merge([
|
||||
for location, ips in local.locations : {
|
||||
for ip in ips : "${location} at ${ip}" => {
|
||||
location = location,
|
||||
ip = ip,
|
||||
}
|
||||
}
|
||||
]...)
|
||||
|
||||
domain = data.digitalocean_domain.ingress.id
|
||||
type = strcontains(each.value.ip, ":") ? "AAAA" : "A"
|
||||
name = lower(each.value.location)
|
||||
value = each.value.ip
|
||||
ttl = 60
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
locals {
|
||||
listeners = [
|
||||
{
|
||||
domain = "k8s.tjo.cloud"
|
||||
name = "api"
|
||||
locations = ["SI", "DE"]
|
||||
},
|
||||
{
|
||||
domain = "k8s.tjo.cloud"
|
||||
name = "dashboard"
|
||||
locations = ["SI", "DE"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
resource "digitalocean_record" "listeners" {
|
||||
for_each = merge(flatten([
|
||||
for listener in local.listeners :
|
||||
[
|
||||
for location in listener.locations : {
|
||||
for ip in local.locations[location] : "${ip} for ${listener.name}.${listener.domain} at ${location}" => {
|
||||
ip = ip
|
||||
domain = listener.domain
|
||||
name = listener.name
|
||||
}
|
||||
}
|
||||
]
|
||||
])...)
|
||||
|
||||
domain = each.value.domain
|
||||
type = strcontains(each.value.ip, ":") ? "AAAA" : "A"
|
||||
name = each.value.name
|
||||
value = each.value.ip
|
||||
ttl = 60
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
digitalocean = {
|
||||
source = "digitalocean/digitalocean"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
dns = {
|
||||
source = "hashicorp/dns"
|
||||
version = "~> 3.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
required_version = "~> 1.7.3"
|
||||
}
|
||||
|
||||
provider "digitalocean" {
|
||||
token = var.digitalocean_token
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
variable "digitalocean_token" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
1
justfile
1
justfile
|
@ -4,7 +4,6 @@ set shell := ["devbox", "run"]
|
|||
set dotenv-load
|
||||
|
||||
mod k8s 'k8s.tjo.cloud'
|
||||
mod proxmox 'proxmox.tjo.cloud'
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
# This file is maintained automatically by "tofu init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.opentofu.org/bpg/proxmox" {
|
||||
version = "0.61.1"
|
||||
constraints = "0.61.1"
|
||||
hashes = [
|
||||
"h1:6kz2Rdjc8+TVq2aUxEQXLOwbb9OdhJJei0L1fC4K2R4=",
|
||||
"zh:27d8b589a2dc1e0a5b0f8ab299b9f3704a2f0b69799d1d4d8845c68056986d1f",
|
||||
"zh:46dfa6b33ddd7007a2144f38090457604eb56a59a303b37bb0ad1be5c84ddaca",
|
||||
"zh:47a1b14a759393c5ecc76f2feb950677c418c910b8c677fde0dd3e4675c41579",
|
||||
"zh:582e49d109d1c2b1f3b1268a7cbc43548f3c6d96a87c92a5428767097a5e383e",
|
||||
"zh:5e98ad6afae5969a4c3ffb14c0484936550c66c8313d7686551c29b633ff32f2",
|
||||
"zh:7b9e24b76f947ab8f1e571cf61beefc983b7d2aa1b85df35c4f015728fe37a38",
|
||||
"zh:8255ca210f279a0f7b8ca2762df26d2ea1a01704298c5e3d5cf601bd39a743f0",
|
||||
"zh:85d7655fdc95dedced9cf8105a0beeb0d7bc8f668c55f62019a7215a76d60300",
|
||||
"zh:8aeea5a1d001b06baaf923b754e1a14d06c75eb8c8b87a7f65a3c8205fc8b079",
|
||||
"zh:a9cfab6c06f613658c5fdd83742cd22c0eb7563778924b1407965ef8c36c1ce0",
|
||||
"zh:ceaab67801d49a92eb5858b1ddae6df2569462e5ffbe31f9dbd79dcb684ea142",
|
||||
"zh:dc25b506d5c55d1d78a335d3ebd03213c99b4b2a5859812349a955c2f746ff7e",
|
||||
"zh:e04b477fd77a0d37a0bdb76a7cf69184dad9e7fbba9b4f3a378a8901b82b75e5",
|
||||
"zh:f1e6838d9141557f73340df9b21fce5a82b41cc16ae36f063a920ccc36bc0758",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
]
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
"${toString modulesPath}/profiles/qemu-guest.nix"
|
||||
];
|
||||
|
||||
system.stateVersion = "24.05";
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
autoResize = true;
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/ESP";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
boot.growPartition = true;
|
||||
boot.kernelParams = [ "console=ttyS0" ];
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.timeout = 0;
|
||||
|
||||
services.qemuGuest.enable = true;
|
||||
|
||||
services.cloud-init = {
|
||||
enable = true;
|
||||
network.enable = true;
|
||||
settings = lib.mkOptionDefault {
|
||||
datasource = {
|
||||
NoCloud = { };
|
||||
ConfigDrive = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Needed due to cloud-init.network.enable = true
|
||||
networking.useNetworkd = true;
|
||||
|
||||
# Create default user
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
nix.settings.trusted-users = [ "nixos" ];
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
password = "hunter2";
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
environment.systemPackages = [ pkgs.nginx ];
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1724316499,
|
||||
"narHash": "sha256-Qb9MhKBUTCfWg/wqqaxt89Xfi6qTD3XpTzQ9eXi3JmE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "797f7dc49e0bc7fab4b57c021cdf68f595e47841",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
description = "Basic NixOS qcow2 image with CloudInit for Proxmox";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
||||
};
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
{
|
||||
nixosConfigurations = {
|
||||
build-qcow2 = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
./qcow2.nix
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
default:
|
||||
@just --list
|
||||
|
||||
build:
|
||||
@nix build .#nixosConfigurations.build-qcow2.config.system.build.qcow2
|
||||
|
||||
apply: build
|
||||
#!/usr/bin/env sh
|
||||
export NIXOS_IMAGE=$(nix path-info --quiet .#nixosConfigurations.build-qcow2.config.system.build.qcow2)/nixos.qcow2
|
||||
export TF_VAR_image_path=$NIXOS_IMAGE
|
||||
|
||||
echo "Deploying $NIXOS_IMAGE"
|
||||
tofu init
|
||||
tofu apply
|
||||
|
||||
destroy:
|
||||
#!/usr/bin/env sh
|
||||
tofu destroy
|
|
@ -1,50 +0,0 @@
|
|||
variable "storage" {
|
||||
type = string
|
||||
default = "proxmox-backup-tjo-cloud"
|
||||
}
|
||||
|
||||
variable "node_name" {
|
||||
type = string
|
||||
default = "hetzner"
|
||||
}
|
||||
|
||||
variable "proxmox_token" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "image_path" {
|
||||
type = string
|
||||
}
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.61.1"
|
||||
}
|
||||
}
|
||||
required_version = "~> 1.7.3"
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
# FIXME: Traefik/NGINX breaks this! 500 ERROR
|
||||
endpoint = "https://178.63.49.225:8006/api2/json"
|
||||
insecure = true
|
||||
api_token = var.proxmox_token
|
||||
ssh {
|
||||
agent = true
|
||||
username = "root"
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "nixos-cloudinit" {
|
||||
content_type = "iso"
|
||||
datastore_id = var.storage
|
||||
node_name = var.node_name
|
||||
|
||||
source_file {
|
||||
path = var.image_path
|
||||
file_name = "nixos-cloudinit.img"
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
system.build.qcow2 = import "${toString modulesPath}/../lib/make-disk-image.nix" {
|
||||
inherit lib config pkgs;
|
||||
name = "nixos";
|
||||
diskSize = "auto";
|
||||
format = "qcow2-compressed";
|
||||
partitionTableType = "efi";
|
||||
copyChannel = true;
|
||||
configFile = pkgs.writeText "configuration.nix" (pkgs.lib.readFile ./configuration.nix);
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue