Skip to content

Commit

Permalink
setup folders
Browse files Browse the repository at this point in the history
  • Loading branch information
teaglebuilt committed Dec 8, 2024
1 parent bd74188 commit d1a7b6e
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 4 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export PROXMOX_VE_USERNAME=root@pam
export PROXMOX_VE_PASSWORD=<your proxmox password>
export GO111MODULE=on
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.env
.envrc
.task
.DS_Store

*.crt
*.key
*.pem
out/
# tf folder
**/.terraform/*
.terraform
.terraform.lock.hcl
*.tfstate
*.tfstate.*
*.tfvars
*.tfvars.json
override.tf
override.tf.json
*_override.tf
*_override.tf.json
7 changes: 4 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: '3'

includes:
vpn: "network/vpn/Taskfile.yml"

tasks:
default:
help:
silent: true
cmds: ["task -l"]

cmds: [ "task -l" ]
File renamed without changes.
16 changes: 16 additions & 0 deletions network/vpn/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CURRENT_DIR ?= $(shell pwd)

tf_init:
@echo "Initializing Terraform..."
@echo "Terraform initialized."

tf_plan:
@echo "Planning VPN..."
@echo "VPN planned."

tf_apply:
@echo "Applying VPN..."
@echo "VPN applied."

provision: tf_init tf_plan tf_apply
@echo "VPN provisioned."
2 changes: 1 addition & 1 deletion network/vpn/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

1. Exoscale
1. Linode Server
2. Algo VPN
8 changes: 8 additions & 0 deletions network/vpn/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'

tasks:
provision:
dir: "network/vpn"
description: "provision a vpn server"
cmds:
- "make provision"
14 changes: 14 additions & 0 deletions network/vpn/terraform/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "tls_private_key" "ssh_key" {
algorithm = "RSA"
rsa_bits = 4096
}

resource "local_file" "private_key" {
content = tls_private_key.ssh_key.private_key_pem
filename = "${path.module}/id_rsa_algo"
}

resource "local_file" "public_key" {
content = tls_private_key.ssh_key.public_key_openssh
filename = "${path.module}/id_rsa_algo.pub"
}
20 changes: 20 additions & 0 deletions network/vpn/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "linode_instance" "linode_server" {
label = "vpn-server"
region = var.region
type = var.instance_type
image = "linode/ubuntu22.04"
root_pass = var.root_password

authorized_keys = [tls_private_key.ssh_key.public_key_openssh]

tags = ["vpn"]
}

module "algo_vpn" {
source = "https://github.com/teaglebuilt/homelab//tf_modules/algo_vpn?ref=main"
server_ip = linode_instance.algo_vpn_server.ip_address
server_user = var.server_user
private_key_path = local_file.private_key.filename
user_name = var.user_name
wireguard_port = var.wireguard_port
}
7 changes: 7 additions & 0 deletions network/vpn/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "server_ip" {
value = linode_instance.algo_vpn_server.ip_address
}

output "algo_config_path" {
value = module.algo_vpn.algo_config_path
}
12 changes: 12 additions & 0 deletions network/vpn/terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "2.5.2"
}
}
}

provider "linode" {
config_path = "~/.config/linode"
}
26 changes: 26 additions & 0 deletions network/vpn/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
variable "linode_api_token" {
description = "API token for Linode"
type = string
}

variable "server_name" {
description = "Name for the Linode server"
type = string
}

variable "region" {
description = "Region for the Linode server"
type = string
default = "us-east"
}

variable "instance_type" {
description = "Linode instance type"
type = string
default = "g6-nanode-1"
}

variable "root_password" {
description = "Root password for the Linode server"
type = string
}
File renamed without changes.
Empty file added packages/soa/README.md
Empty file.
Empty file added packages/soa/Taskfile.yml
Empty file.
42 changes: 42 additions & 0 deletions packages/soa/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module github.com/teaglebuilt/homelab

go 1.23.2

require (
dagger.io/dagger v0.14.0 // indirect
github.com/99designs/gqlgen v0.17.55 // indirect
github.com/Khan/genqlient v0.7.0 // indirect
github.com/adrg/xdg v0.5.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/sosodev/duration v1.3.1 // indirect
github.com/vektah/gqlparser/v2 v2.5.17 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 // indirect
go.opentelemetry.io/otel/log v0.3.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/sdk/log v0.3.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
73 changes: 73 additions & 0 deletions packages/soa/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
dagger.io/dagger v0.14.0 h1:Ld19wPlbIkeMnOlxS0K1Cq4PHbXEQyUWuJnmlBtNo+g=
dagger.io/dagger v0.14.0/go.mod h1:YCNpoHLR3fiqE7a0yZs06rqD4+oXI9r/u7l6om1w0pI=
github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM=
github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/adrg/xdg v0.5.1 h1:Im8iDbEFARltY09yOJlSGu4Asjk2vF85+3Dyru8uJ0U=
github.com/adrg/xdg v0.5.1/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/vektah/gqlparser/v2 v2.5.17 h1:9At7WblLV7/36nulgekUgIaqHZWn5hxqluxrxGUhOmI=
github.com/vektah/gqlparser/v2 v2.5.17/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg=
go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 h1:bFgvUr3/O4PHj3VQcFEuYKvRZJX1SJDQ+11JXuSB3/w=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0/go.mod h1:xJntEd2KL6Qdg5lwp97HMLQDVeAhrYxmzFseAMDPQ8I=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 h1:CIHWikMsN3wO+wq1Tp5VGdVRTcON+DmOJSfDjXypKOc=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0/go.mod h1:TNupZ6cxqyFEpLXAZW7On+mLFL0/g0TE3unIYL91xWc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY=
go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs=
go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys=
go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik=
go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak=
go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI=
go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A=
go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U=
go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g=
go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2NemcCrOL8gI=
go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw=
go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw=
go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
Empty file added packages/soa/internal/.gitkeep
Empty file.
Empty file added packages/soa/main.go
Empty file.
Empty file added packages/soa/pkg/.gitkeep
Empty file.
Empty file added packages/soa/vendor/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions tf_modules/algo_vpn/algo-config.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
users:
- name: "${vpn_user_name}"
type: "wireguard"
dns:
enabled: true
provider: "adguard"
wireguard:
enabled: true
port: ${wireguard_port}
32 changes: 32 additions & 0 deletions tf_modules/algo_vpn/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "local_file" "algo_config" {
content = templatefile("${path.module}/algo-config.tmpl", {
user_name = var.user_name
wireguard_port = var.wireguard_port
})
filename = "${path.module}/algo-config.yaml"
}

resource "null_resource" "provision_algo" {
depends_on = [local_file.algo_config]

connection {
type = "ssh"
host = var.server_ip
user = var.server_user
private_key = file(var.private_key_path)
}

provisioner "file" {
source = local_file.algo_config.filename
destination = "/home/${var.server_user}/algo-config.yaml"
}

provisioner "remote-exec" {
inline = [
"sudo apt update && sudo apt install -y python3-pip git",
"git clone https://github.com/trailofbits/algo.git",
"cd algo && python3 -m pip install -r requirements.txt",
"cd algo && ./algo --auto --config /home/${var.server_user}/algo-config.yaml"
]
}
}
4 changes: 4 additions & 0 deletions tf_modules/algo_vpn/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "algo_config_path" {
description = "The local path to the generated AlgoVPN configuration file."
value = local_file.algo_config.filename
}
27 changes: 27 additions & 0 deletions tf_modules/algo_vpn/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
variable "server_ip" {
description = "The public IP address of the server where AlgoVPN will be provisioned."
type = string
}

variable "server_user" {
description = "The SSH user for accessing the server."
type = string
default = "algo"
}

variable "private_key_path" {
description = "Path to the private SSH key for accessing the server."
type = string
}

variable "user_name" {
description = "The VPN user name to be configured in AlgoVPN."
type = string
default = "vpnuser"
}

variable "wireguard_port" {
description = "The port for WireGuard VPN connections."
type = number
default = 51820
}

0 comments on commit d1a7b6e

Please sign in to comment.