From fc3e06cf06ff6f06e9958d1c972c9411aaff2c64 Mon Sep 17 00:00:00 2001 From: Harrison Affel Date: Mon, 30 Sep 2024 11:28:26 -0400 Subject: [PATCH] Bump default rke2 version, remove naming convention check, bump azure provider version, add scoop install script in dev builds --- terraform/azure_active_directory/providers.tf | 2 +- terraform/azure_docker_rancher/providers.tf | 2 +- terraform/azure_rke2_cluster/providers.tf | 2 +- terraform/azure_rke2_cluster/variables.tf | 2 +- .../azure_server/examples/windows_dev.tfvars | 2 +- .../azure_server/files/install_choco.ps1 | 27 ------------------- .../azure_server/files/install_scoop.ps1 | 8 ++++++ .../files/install_scoop_tools.ps1 | 3 +++ .../azure_server/files/setup_profile.ps1 | 4 +-- terraform/azure_server/main.tf | 7 ++--- terraform/azure_server/providers.tf | 2 +- terraform/azure_server/variables.tf | 5 ---- terraform/internal/azure/vm/output.tf | 4 +++ .../rancher/rke2/cluster/variables.tf | 2 +- 14 files changed, 27 insertions(+), 45 deletions(-) delete mode 100644 terraform/azure_server/files/install_choco.ps1 create mode 100644 terraform/azure_server/files/install_scoop.ps1 create mode 100644 terraform/azure_server/files/install_scoop_tools.ps1 diff --git a/terraform/azure_active_directory/providers.tf b/terraform/azure_active_directory/providers.tf index 5007787..f1e684f 100644 --- a/terraform/azure_active_directory/providers.tf +++ b/terraform/azure_active_directory/providers.tf @@ -2,7 +2,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "3.56.0" + version = "3.90.0" } } } diff --git a/terraform/azure_docker_rancher/providers.tf b/terraform/azure_docker_rancher/providers.tf index a1818bd..8e66ff4 100644 --- a/terraform/azure_docker_rancher/providers.tf +++ b/terraform/azure_docker_rancher/providers.tf @@ -2,7 +2,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "3.56.0" + version = "3.90.0" } digitalocean = { source = "digitalocean/digitalocean" diff --git a/terraform/azure_rke2_cluster/providers.tf b/terraform/azure_rke2_cluster/providers.tf index 9bf2420..f730882 100644 --- a/terraform/azure_rke2_cluster/providers.tf +++ b/terraform/azure_rke2_cluster/providers.tf @@ -2,7 +2,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "3.56.0" + version = "3.90.0" } kubernetes = { source = "hashicorp/kubernetes" diff --git a/terraform/azure_rke2_cluster/variables.tf b/terraform/azure_rke2_cluster/variables.tf index 4774c42..e1f3354 100644 --- a/terraform/azure_rke2_cluster/variables.tf +++ b/terraform/azure_rke2_cluster/variables.tf @@ -6,7 +6,7 @@ variable "name" { variable "kubernetes_version" { type = string description = "The version of RKE2 that you would like to use to provision a cluster." - default = "v1.25.16+rke2r1" + default = "v1.29.8+rke2r1" } variable "active_directory" { diff --git a/terraform/azure_server/examples/windows_dev.tfvars b/terraform/azure_server/examples/windows_dev.tfvars index 14cbb5b..17a5c30 100644 --- a/terraform/azure_server/examples/windows_dev.tfvars +++ b/terraform/azure_server/examples/windows_dev.tfvars @@ -1,2 +1,2 @@ -image = "windows" +image = "windows-2022" dev_tools = true \ No newline at end of file diff --git a/terraform/azure_server/files/install_choco.ps1 b/terraform/azure_server/files/install_choco.ps1 deleted file mode 100644 index 7e61fec..0000000 --- a/terraform/azure_server/files/install_choco.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -if (Get-Command choco -ErrorAction SilentlyContinue) { - Write-Host 'choco is already installed.' -ForegroundColor Green -} else { - Write-Host 'Installing choco...' -ForegroundColor Green - Set-ExecutionPolicy Bypass -Scope Process -Force; - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; - iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); -} - -$null = Import-Module "C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1" - -if (-not (Get-Command refreshenv -ErrorAction SilentlyContinue)) { - throw "Could not find refreshenv. Something is wrong with your chocolatey installation." -} - -$null = refreshenv - -$tools = @("go", "git", "kubernetes-cli") - -foreach ($tool in $tools) { - if (Get-Command $tool -ErrorAction SilentlyContinue) { - Write-Host "$tool is already installed." -ForegroundColor Green - continue - } - Write-Host "Installing $tool..." -ForegroundColor Green - choco install $tool -y; -} diff --git a/terraform/azure_server/files/install_scoop.ps1 b/terraform/azure_server/files/install_scoop.ps1 new file mode 100644 index 0000000..4b2f0f1 --- /dev/null +++ b/terraform/azure_server/files/install_scoop.ps1 @@ -0,0 +1,8 @@ +# Install scoop globally +$env:SCOOP="C:\ProgramData\Scoop" +$env:SCOOP_GLOBAL = "C:\ProgramData\Scoop" +[Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'Machine') +[Environment]::SetEnvironmentVariable('SCOOP_GLOBAL', $env:SCOOP_GLOBAL, 'Machine') + +irm get.scoop.sh -outfile 'install.ps1' +iex "& {$(irm get.scoop.sh)} -RunAsAdmin" diff --git a/terraform/azure_server/files/install_scoop_tools.ps1 b/terraform/azure_server/files/install_scoop_tools.ps1 new file mode 100644 index 0000000..e235dfa --- /dev/null +++ b/terraform/azure_server/files/install_scoop_tools.ps1 @@ -0,0 +1,3 @@ +scoop install go +scoop install git +scoop install mage diff --git a/terraform/azure_server/files/setup_profile.ps1 b/terraform/azure_server/files/setup_profile.ps1 index 7dd34a9..801e393 100644 --- a/terraform/azure_server/files/setup_profile.ps1 +++ b/terraform/azure_server/files/setup_profile.ps1 @@ -54,11 +54,9 @@ if (!(Test-Path -Path $PROFILE.AllUsersCurrentHost)) { } $profileFile = @" -`$env:PATH += ";C:\ProgramData\chocolatey\bin" - -`$null = Import-Module C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1 `$null = refreshenv `$null = Import-Module -WarningAction Ignore -Name `"$toolsPsm1Path`" +`$env:PATH += "C:\ProgramData\Scoop\shims" Set-Item -Path Env:\CRI_CONFIG_FILE -Value `$env:ProgramData\crictl\crictl.yaml "@ diff --git a/terraform/azure_server/main.tf b/terraform/azure_server/main.tf index 87f8343..e1ec41d 100644 --- a/terraform/azure_server/main.tf +++ b/terraform/azure_server/main.tf @@ -5,12 +5,13 @@ module "images" { locals { scripts = var.dev_tools && module.images.source_images[var.image].os == "windows" ? concat( [ - file("${path.module}/files/enable_features.ps1"), - file("${path.module}/files/install_choco.ps1"), file("${path.module}/files/setup_profile.ps1"), file("${path.module}/files/install_docker.ps1"), file("${path.module}/files/install_containerd.ps1"), - file("${path.module}/files/install_wsl.ps1") + file("${path.module}/files/install_wsl.ps1"), + file("${path.module}/files/install_scoop.ps1"), + file("${path.module}/files/install_scoop_tools.ps1"), + file("${path.module}/files/enable_features.ps1") ], var.scripts ) : var.scripts diff --git a/terraform/azure_server/providers.tf b/terraform/azure_server/providers.tf index 2936dc8..fea9ba3 100644 --- a/terraform/azure_server/providers.tf +++ b/terraform/azure_server/providers.tf @@ -2,7 +2,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "3.56.0" + version = "3.90.0" } } } diff --git a/terraform/azure_server/variables.tf b/terraform/azure_server/variables.tf index 01844d8..7990e5e 100644 --- a/terraform/azure_server/variables.tf +++ b/terraform/azure_server/variables.tf @@ -3,11 +3,6 @@ variable "name" { type = string description = "The name of the server you would like to provision." - - validation { - condition = endswith(var.name, "-server") - error_message = "Name must end with -server" - } } variable "replicas" { diff --git a/terraform/internal/azure/vm/output.tf b/terraform/internal/azure/vm/output.tf index 03405bf..87824e8 100644 --- a/terraform/internal/azure/vm/output.tf +++ b/terraform/internal/azure/vm/output.tf @@ -39,6 +39,10 @@ locals { "@ + + # Monitor the initialization scripts. These can take several minutes to complete. + while(1){Get-ScheduledTask -TaskPath "\Rancher\Terraform\"; sleep 5; clear} + EOT linux = <<-EOT # Check all stderr logs from initialization scripts diff --git a/terraform/internal/rancher/rke2/cluster/variables.tf b/terraform/internal/rancher/rke2/cluster/variables.tf index 2f1c29c..1a6e834 100644 --- a/terraform/internal/rancher/rke2/cluster/variables.tf +++ b/terraform/internal/rancher/rke2/cluster/variables.tf @@ -6,5 +6,5 @@ variable "name" { variable "kubernetes_version" { type = string description = "The version of RKE2 that you would like to use to provision a cluster." - default = "v1.24.13+rke2r1" + default = "v1.29.8+rke2r1" }