diff --git a/recipes/upstream/aws/k3s/main.tf b/recipes/upstream/aws/k3s/main.tf index fe61f54..d7b9b08 100644 --- a/recipes/upstream/aws/k3s/main.tf +++ b/recipes/upstream/aws/k3s/main.tf @@ -1,7 +1,6 @@ locals { - kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd - kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml" - kc_file_backup = "${local.kc_file}.backup" + kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd + kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml" } module "k3s_first" { @@ -90,13 +89,13 @@ resource "ssh_resource" "retrieve_kubeconfig" { } resource "local_file" "kube_config_yaml" { - filename = local.kc_file + filename = pathexpand(local.kc_file) content = ssh_resource.retrieve_kubeconfig.result file_permission = "0600" } resource "local_file" "kube_config_yaml_backup" { - filename = local.kc_file_backup + filename = pathexpand("${local.kc_file}.backup") content = ssh_resource.retrieve_kubeconfig.result file_permission = "0600" } diff --git a/recipes/upstream/aws/k3s/terraform.tfvars.example b/recipes/upstream/aws/k3s/terraform.tfvars.example index 5fb3ee4..015e48f 100644 --- a/recipes/upstream/aws/k3s/terraform.tfvars.example +++ b/recipes/upstream/aws/k3s/terraform.tfvars.example @@ -52,5 +52,6 @@ create_ssh_key_pair = true # ssh_key_pair_path = "/path/to/private/key.pem" ##### -## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path -# kube_config_path = "~/.kube/rancher-terraform.yml" +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" diff --git a/recipes/upstream/aws/rke/main.tf b/recipes/upstream/aws/rke/main.tf index 96a5823..955feab 100644 --- a/recipes/upstream/aws/rke/main.tf +++ b/recipes/upstream/aws/rke/main.tf @@ -26,7 +26,6 @@ module "rke" { kube_config_path = var.kube_config_path kube_config_filename = var.kube_config_filename kubernetes_version = var.kubernetes_version - } locals { diff --git a/recipes/upstream/aws/rke/terraform.tfvars.example b/recipes/upstream/aws/rke/terraform.tfvars.example index 9f1a542..e55711e 100644 --- a/recipes/upstream/aws/rke/terraform.tfvars.example +++ b/recipes/upstream/aws/rke/terraform.tfvars.example @@ -47,5 +47,6 @@ create_ssh_key_pair = true # ssh_key_pair_path = "/path/to/private/key.pem" ##### -## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path -# kube_config_path = "~/.kube/rancher-terraform.yml" \ No newline at end of file +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" \ No newline at end of file diff --git a/recipes/upstream/aws/rke2/main.tf b/recipes/upstream/aws/rke2/main.tf index d12eb65..1d51f87 100644 --- a/recipes/upstream/aws/rke2/main.tf +++ b/recipes/upstream/aws/rke2/main.tf @@ -1,7 +1,6 @@ locals { - kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd - kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml" - kc_file_backup = "${local.kc_file}.backup" + kc_path = var.kube_config_path != null ? var.kube_config_path : path.cwd + kc_file = var.kube_config_filename != null ? "${local.kc_path}/${var.kube_config_filename}" : "${local.kc_path}/${var.prefix}_kube_config.yml" } module "rke2_first" { @@ -71,13 +70,13 @@ resource "ssh_resource" "retrieve_kubeconfig" { } resource "local_file" "kube_config_yaml" { - filename = local.kc_file + filename = pathexpand(local.kc_file) content = ssh_resource.retrieve_kubeconfig.result file_permission = "0600" } resource "local_file" "kube_config_yaml_backup" { - filename = local.kc_file_backup + filename = pathexpand("${local.kc_file}.backup") content = ssh_resource.retrieve_kubeconfig.result file_permission = "0600" } diff --git a/recipes/upstream/aws/rke2/terraform.tfvars.example b/recipes/upstream/aws/rke2/terraform.tfvars.example index e3f49a7..ece1e72 100644 --- a/recipes/upstream/aws/rke2/terraform.tfvars.example +++ b/recipes/upstream/aws/rke2/terraform.tfvars.example @@ -50,5 +50,6 @@ create_ssh_key_pair = true # ssh_key_pair_path = "/path/to/private/key.pem" ##### -## -- Override the default (${prefix}_kube_config.yml) kubeconfig file/path -# kube_config_path = "~/.kube/rancher-terraform.yml" +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" \ No newline at end of file diff --git a/recipes/upstream/digitalocean/rke/terraform.tfvars.example b/recipes/upstream/digitalocean/rke/terraform.tfvars.example index 50aaded..8b004fa 100644 --- a/recipes/upstream/digitalocean/rke/terraform.tfvars.example +++ b/recipes/upstream/digitalocean/rke/terraform.tfvars.example @@ -40,8 +40,9 @@ # If 'create_ssh_key_pair' is set to false, give the name of an ssh key on DigitalOcean # ssh_key_pair_name = "terraform" -# Filepath to the private ssh key to be uploaded or already existing on DigitalOcean -# ssh_key_pair_path = "~/.ssh/terraform" +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" # DigitalOcean authentication token # do_token = "" diff --git a/recipes/upstream/google-cloud/k3s/main.tf b/recipes/upstream/google-cloud/k3s/main.tf index 29958bd..7ab120f 100644 --- a/recipes/upstream/google-cloud/k3s/main.tf +++ b/recipes/upstream/google-cloud/k3s/main.tf @@ -115,11 +115,9 @@ resource "ssh_resource" "retrieve_kubeconfig" { } resource "local_file" "kube_config_yaml" { - depends_on = [ssh_resource.retrieve_kubeconfig] - - filename = local.kc_file - file_permission = "0600" + filename = pathexpand(local.kc_file) content = ssh_resource.retrieve_kubeconfig.result + file_permission = "0600" } provider "kubernetes" { diff --git a/recipes/upstream/google-cloud/k3s/terraform.tfvars.example b/recipes/upstream/google-cloud/k3s/terraform.tfvars.example index c567cab..adf0bbf 100644 --- a/recipes/upstream/google-cloud/k3s/terraform.tfvars.example +++ b/recipes/upstream/google-cloud/k3s/terraform.tfvars.example @@ -75,11 +75,9 @@ ssh_username = "ubuntu" ## -- K3s custom config file # k3s_config = "" -## -- K3s KUBECONFIG file path -# kube_config_path = "" - -## -- K3s KUBECONFIG file -# kube_config_filename = "" +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" ## -- Bootstrap the Rancher installation # bootstrap_rancher = false diff --git a/recipes/upstream/google-cloud/rke2/main.tf b/recipes/upstream/google-cloud/rke2/main.tf index 87f7ca0..46d8380 100644 --- a/recipes/upstream/google-cloud/rke2/main.tf +++ b/recipes/upstream/google-cloud/rke2/main.tf @@ -91,11 +91,9 @@ resource "ssh_resource" "retrieve_kubeconfig" { } resource "local_file" "kube_config_yaml" { - depends_on = [ssh_resource.retrieve_kubeconfig] - - filename = local.kc_file - file_permission = "0600" + filename = pathexpand(local.kc_file) content = ssh_resource.retrieve_kubeconfig.result + file_permission = "0600" } provider "kubernetes" { diff --git a/recipes/upstream/google-cloud/rke2/terraform.tfvars.example b/recipes/upstream/google-cloud/rke2/terraform.tfvars.example index 940a2cb..07a4330 100644 --- a/recipes/upstream/google-cloud/rke2/terraform.tfvars.example +++ b/recipes/upstream/google-cloud/rke2/terraform.tfvars.example @@ -69,11 +69,9 @@ ssh_username = "ubuntu" ## -- RKE2 custom config file # rke2_config = "" -## -- RKE2 KUBECONFIG file path -# kube_config_path = "" - -## -- RKE2 KUBECONFIG file -# kube_config_filename = "" +## -- Override the default (./${prefix}_kube_config.yml) kubeconfig path and filename +# kube_config_path = "~/.kube" +# kube_config_filename = "rancher-terraform.yml" ## -- Bootstrap the Rancher installation # bootstrap_rancher = false