Skip to content

Commit

Permalink
setup makefile to run tf
Browse files Browse the repository at this point in the history
  • Loading branch information
teaglebuilt committed Dec 15, 2024
1 parent ed3e815 commit ea6ac54
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3'

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

tasks:
help:
Expand Down
8 changes: 5 additions & 3 deletions kubernetes/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
TERRAFORM=./terraform

TERRAFORM=terraform -chdir=terraform

init:
$(TERRAFORM) init
Expand All @@ -8,4 +7,7 @@ plan:
$(TERRAFORM) plan

apply:
$(TERRAFORM) apply -auto-approve
$(TERRAFORM) apply -auto-approve \
-var-file=terraform.tfvars

tf_run: init plan apply
20 changes: 18 additions & 2 deletions kubernetes/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
version: 3

tasks:
provision_administration:
generate_tf_variables:
dir: kubernetes
cmds:
-
- |
echo "Generating terraform.tfvars from .env file..."
if [ -f .env ]; then
awk -F= '/^[^#]+/ {print $1 " = \"" $2 "\""}' .env > terraform/terraform.tfvars
else
echo "No .env file found. Skipping terraform.tfvars generation."
fi
silent: true
sources:
- .env

provision_administration_cluster:
dir: kubernetes
cmds:
- task: generate_tf_variables
- make tf_run
8 changes: 4 additions & 4 deletions kubernetes/terraform/administration-cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ resource "proxmox_vm_qemu" "k8s_cp_01" {
bridge = "vmbr0"
}

ipconfig0 = "ip=192.168.1.100/24,gw=192.168.1.1"
sshkeys = file("~/.ssh/id_rsa.pub")
ipconfig0 = "ip=${var.proxmox_node_cidr},gw=${var.gateway}"
sshkeys = file("${var.ssh_public_key_path}")
}

resource "proxmox_vm_qemu" "k8s_worker_01" {
Expand All @@ -31,8 +31,8 @@ resource "proxmox_vm_qemu" "k8s_worker_01" {
bridge = "vmbr0"
}

ipconfig0 = "ip=192.168.1.100/24,gw=192.168.1.1"
sshkeys = file("~/.ssh/id_rsa.pub")
ipconfig0 = "ip=${var.proxmox_node_cidr},gw=${var.gateway}"
sshkeys = file("${var.ssh_public_key_path}")
}

module "k8s_administration_cluster" {
Expand Down

0 comments on commit ea6ac54

Please sign in to comment.