Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions examples/downstream/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.1"
Expand Down
4 changes: 0 additions & 4 deletions examples/downstream_splitrole/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.1"
Expand Down
4 changes: 0 additions & 4 deletions examples/one/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.1"
Expand Down
4 changes: 0 additions & 4 deletions examples/prod/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.1"
Expand Down
28 changes: 14 additions & 14 deletions examples/three/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ locals {
indirect_access = true
initial = true
}
# "rancherB" = {
# type = "all-in-one"
# size = "xxl"
# os = local.os
# indirect_access = true
# initial = false
# }
# "rancherC" = {
# type = "all-in-one"
# size = "xxl"
# os = local.os
# indirect_access = true
# initial = false
# }
"rancherB" = {
type = "all-in-one"
size = "xxl"
os = local.os
indirect_access = true
initial = false
}
"rancherC" = {
type = "all-in-one"
size = "xxl"
os = local.os
indirect_access = true
initial = false
}
}
local_file_path = var.file_path
runner_ip = chomp(data.http.myip.response_body) # "runner" is the server running Terraform
Expand Down
4 changes: 0 additions & 4 deletions examples/three/modules/tls/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
tls = {
source = "hashicorp/tls"
version = ">= 4.0.5"
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

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

81 changes: 70 additions & 11 deletions modules/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,39 @@ module "deploy_initial_node" {
depends_on = [
data.aws_availability_zones.available,
]
for_each = local.initial_node
deploy_path = each.value.deploy_path
data_path = each.value.deploy_path
template_path = "${path.module}/node_template"
for_each = local.initial_node
deploy_path = each.value.deploy_path
data_path = each.value.deploy_path
# if any of this changes, update/redeploy
deploy_trigger = md5(join("-", [
each.key,
md5(base64encode(jsonencode(each.value))),
local.identifier,
local.owner,
local.acme_server_url,
local.project_name,
local.ip_family,
md5(base64encode(jsonencode(data.aws_availability_zones.available.names))),
md5(base64encode(jsonencode(local.project_subnet_names))),
md5(base64encode(jsonencode(local.project_load_balancer_access_cidrs))),
local.domain,
local.zone,
local.skip_cert,
data.aws_availability_zones.available.names[0],
md5(base64encode(jsonencode(values(local.target_groups)))),
md5(base64encode(jsonencode(local.server_access_addresses))),
local.username,
local.ssh_key,
local.install_method,
local.download,
local.rke2_version,
]))
template_files = [
join("/", [path.module, "node_template", "main.tf"]),
join("/", [path.module, "node_template", "outputs.tf"]),
join("/", [path.module, "node_template", "variables.tf"]),
join("/", [path.module, "node_template", "versions.tf"]),
]
inputs = <<-EOT
identifier = "${local.identifier}"
owner = "${local.owner}"
Expand Down Expand Up @@ -229,10 +258,39 @@ module "deploy_additional_nodes" {
data.aws_availability_zones.available,
module.deploy_initial_node,
]
for_each = local.additional_nodes
deploy_path = each.value.deploy_path
data_path = each.value.deploy_path
template_path = "${path.module}/node_template"
for_each = local.additional_nodes
deploy_path = each.value.deploy_path
data_path = each.value.deploy_path
# if any of this changes, update/redeploy
deploy_trigger = md5(join("-", [
each.key,
md5(base64encode(jsonencode(each.value))),
local.identifier,
local.owner,
local.acme_server_url,
local.project_name,
local.ip_family,
md5(base64encode(jsonencode(data.aws_availability_zones.available.names))),
md5(base64encode(jsonencode(local.project_subnet_names))),
md5(base64encode(jsonencode(local.project_load_balancer_access_cidrs))),
local.domain,
local.zone,
local.skip_cert,
data.aws_availability_zones.available.names[0],
md5(base64encode(jsonencode(values(local.target_groups)))),
md5(base64encode(jsonencode(local.server_access_addresses))),
local.username,
local.ssh_key,
local.install_method,
local.download,
local.rke2_version,
]))
template_files = [
join("/", [path.module, "node_template", "main.tf"]),
join("/", [path.module, "node_template", "outputs.tf"]),
join("/", [path.module, "node_template", "variables.tf"]),
join("/", [path.module, "node_template", "versions.tf"]),
]
inputs = <<-EOT
identifier = "${local.identifier}"
owner = "${local.owner}"
Expand Down Expand Up @@ -311,11 +369,12 @@ strcontains(each.value.type, "database") ? local.database_config :
EOT
}

resource "local_sensitive_file" "kubeconfig" {
resource "file_local" "kubeconfig" {
depends_on = [
module.deploy_initial_node,
module.deploy_additional_nodes,
]
content = local.ino.output.kubeconfig
filename = "${local.local_file_path}/kubeconfig"
name = "kubeconfig"
directory = local.local_file_path
contents = local.ino.output.kubeconfig
}
4 changes: 0 additions & 4 deletions modules/cluster/node_template/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.1"
Expand Down
6 changes: 3 additions & 3 deletions modules/cluster/versions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
terraform {
required_version = ">= 1.5.0"
required_providers {
local = {
source = "hashicorp/local"
version = ">= 2.5"
file = {
source = "rancher/file"
version = ">= 1.1"
}
random = {
source = "hashicorp/random"
Expand Down
3 changes: 1 addition & 2 deletions modules/deploy/create.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
${export_contents}
cd ${deploy_path}
export TF_DATA_DIR="${tf_data_dir}"
source envrc
TF_CLI_ARGS_init=""
TF_CLI_ARGS_apply=""

Expand Down
3 changes: 1 addition & 2 deletions modules/deploy/destroy.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
${export_contents}
cd ${deploy_path}
source envrc
TF_CLI_ARGS_init=""
TF_CLI_ARGS_apply=""
export TF_DATA_DIR="${tf_data_dir}"
if [ -z "${skip_destroy}" ]; then
timeout -k 1m ${timeout} terraform init -upgrade -reconfigure
timeout -k 1m ${timeout} terraform destroy -var-file="${deploy_path}/inputs.tfvars" -auto-approve -state="${deploy_path}/tfstate" || true
Expand Down
Loading