Skip to content

Commit

Permalink
(chore) Move and update configs, scripts and terraform to new folders
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter136 committed Apr 14, 2024
1 parent 437353a commit 01c9c53
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 74 deletions.
5 changes: 0 additions & 5 deletions 010-scripts/build

This file was deleted.

4 changes: 0 additions & 4 deletions 010-scripts/generate_configs

This file was deleted.

17 changes: 0 additions & 17 deletions 010-scripts/getconfigs

This file was deleted.

43 changes: 0 additions & 43 deletions 010-scripts/terraform

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ kubernetes_version = "{{ (datasource "inventory").kubernetes_version }}"
talos_version = "{{ (datasource "inventory").talos_version }}"
{{ end -}}

{{ defineDatasource "inventory" "000-configs/inventory.yaml" }}
{{- $outPath := "000-configs/generated_configs/cluster-build.tfvars" }}
{{ defineDatasource "inventory" "configs/inventory.yaml" }}
{{- $outPath := "configs/generated_configs/cluster-build.tfvars" }}
{{- tmpl.Exec "talostfvars" | file.Write $outPath }}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ cluster:
{{ end }}
{{ end }}

{{ defineDatasource "inventory" "000-configs/inventory.yaml" }}
{{ defineDatasource "inventory" "configs/inventory.yaml" }}
{{- range $node := (datasource "inventory").nodes}}
{{- $ctx := dict "node" $node }}
{{- $outPath := printf "000-configs/generated_configs/%s.yaml" $node.name }}
{{- $outPath := printf "configs/generated_configs/%s.yaml" $node.name }}
{{- tmpl.Exec "machineconfigtemplate" $ctx | file.Write $outPath }}
{{- end -}}
5 changes: 5 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

./scripts/generate_configs
./scripts/terraform -c -a
./scripts/getconfigs
4 changes: 4 additions & 0 deletions scripts/generate_configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

gomplate -f configs/templates/machineconfig.yaml.tmpl
gomplate -f configs/templates/cluster-build.tfvars.tmpl
17 changes: 17 additions & 0 deletions scripts/getconfigs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

overwrite=false

while getopts "o" arg; do
case $arg in
o) overwrite=true
esac
done

terraform -chdir="./terraform/talos" output -raw talos_config > configs/generated_configs/TALOS_CONFIG
terraform -chdir="./terraform/talos" output -raw kube_config > configs/generated_configs/KUBE_CONFIG

if $overwrite; then
cp configs/generated_configs/TALOS_CONFIG ~/.talos/config
cp configs/generated_configs/KUBE_CONFIG ~/.kube/config
fi
43 changes: 43 additions & 0 deletions scripts/terraform
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

apply=false
upgrade=false
init=false
cluster=false
external=false
while getopts "auice" arg; do
case $arg in
a) apply=true;;
u) upgrade=true;;
i) init=true;;
c) cluster=true;;
e) external=true;;
esac
done

if $external; then
if $upgrade; then
terraform -chdir="./terraform/external-cluster-dependencies" init -upgrade
elif $init; then
terraform -chdir="./terraform/external-cluster-dependencies"
fi
if $apply; then
terraform -chdir="./terraform/external-cluster-dependencies" apply -var-file=../../configs/generated_configs/external.tfvars -auto-approve
else
terraform -chdir="./terraform/external-cluster-dependencies" plan -var-file=../../configs/generated_configs/external.tfvars -no-color > configs/generated_configs/310.tfplan
cat configs/generated_configs/310.tfplan
fi
fi
if $cluster; then
if $upgrade; then
terraform -chdir="./terraform/talos" init -upgrade
elif $init; then
terraform -chdir="./terraform/talos" init
fi
if $apply; then
terraform -chdir="./terraform/talos" apply -var-file=../../configs/generated_configs/cluster-build.tfvars -auto-approve
else
terraform -chdir="./terraform/talos" plan -var-file=../../configs/generated_configs/cluster-build.tfvars -no-color > configs/generated_configs/100.tfplan
cat configs/generated_configs/100.tfplan
fi
fi
2 changes: 1 addition & 1 deletion 100-cluster-build/main.tf → terraform/talos/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
config_directory = "../000-configs/generated_configs"
config_directory = "../../configs/generated_configs"
node_identities = merge(var.controlplane, var.worker)
nodes = keys(local.node_identities)
apply_mode = "staged"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 01c9c53

Please sign in to comment.