Skip to content

Commit 47af38c

Browse files
committed
work around windows vms not allowing ssh keys
1 parent 06389c0 commit 47af38c

File tree

3 files changed

+31
-80
lines changed

3 files changed

+31
-80
lines changed

Diff for: test_code/AZURE_MACHINES/main.tf

+4-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ locals {
1010

1111
combined_instances = merge(local.compute_instances, local.win_instances)
1212

13-
}
13+
additional_custom_data = "Add-Content -Path c:\\users\\test-user\\.ssh\\authorized_keys -Value \"${(var.CI) ? var.PUBLIC_KEY : file(var.public_key_path)}\""
1414

15-
data "template_file" "init" {
16-
template = "${file("${path.module}../user_data/azure_windows.ps.tpl")}"
17-
vars = {
18-
public_key = (var.CI) ? var.PUBLIC_KEY : file(var.public_key_path)
19-
}
2015
}
2116

17+
2218
resource "azurerm_resource_group" "linux_host_test" {
2319
name = format(var.name_format, "linux-host-test-resources")
2420
location = var.location
@@ -88,5 +84,6 @@ resource "azurerm_windows_virtual_machine" "linux_host_test" {
8884
version = each.value.source_image_reference.version
8985
}
9086

91-
custom_data = filebase64(data.template_file.init.rendered)
87+
# custom_data = filebase64("${each.value.user_data}\n${local.additional_custom_data}")
88+
custom_data = base64encode("${file("${path.module}/../user_data/windows.ps")}\n${local.additional_custom_data}")
9289
}

Diff for: test_code/main.tf

+27-27
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@ locals {
22
name_format = var.CI == true ? "gha-lht-${var.WORKFLOW_MATRIX_VALUE}-%s" : var.name_format
33
}
44

5-
module "aws_machines" {
6-
source = "./AWS_MACHINES"
7-
PUBLIC_KEY_PATH = var.PUBLIC_KEY_PATH
8-
PRIVATE_KEY_PATH = var.PRIVATE_KEY_PATH
9-
# REGION = "us-west-2"
10-
name_format = local.name_format
11-
AWS_MACHINE_FILTER = ["AMAZON_LINUX_2", "UBUNTU_18_04_LTS", "UBUNTU_20_04_LTS", "RHEL_8_4_0", "CENT_OS_7", "AMAZON_LINUX_2023"]
12-
CI = var.CI
13-
PUBLIC_KEY = var.PUBLIC_KEY
5+
# module "aws_machines" {
6+
# source = "./AWS_MACHINES"
7+
# PUBLIC_KEY_PATH = var.PUBLIC_KEY_PATH
8+
# PRIVATE_KEY_PATH = var.PRIVATE_KEY_PATH
9+
# # REGION = "us-west-2"
10+
# name_format = local.name_format
11+
# AWS_MACHINE_FILTER = ["AMAZON_LINUX_2", "UBUNTU_18_04_LTS", "UBUNTU_20_04_LTS", "RHEL_8_4_0", "CENT_OS_7", "AMAZON_LINUX_2023"]
12+
# CI = var.CI
13+
# PUBLIC_KEY = var.PUBLIC_KEY
1414

15-
providers = {
16-
aws = aws
17-
}
18-
}
15+
# providers = {
16+
# aws = aws
17+
# }
18+
# }
1919

20-
module "gcp_machines" {
21-
source = "./GCP_MACHINES"
22-
public_key_path = var.PUBLIC_KEY_PATH
23-
PRIVATE_KEY_PATH = var.PRIVATE_KEY_PATH
24-
region = "us-west1"
25-
zone = "a"
26-
name_format = local.name_format
27-
GCP_COMPUTE_FILTER = ["UBUNTU_18_04_LTS", "UBUNTU_20_04_LTS", "UBUNTU_22_04_LTS", "RHEL_8", "CENTOS_8"]
28-
CI = var.CI
29-
PUBLIC_KEY = var.PUBLIC_KEY
20+
# module "gcp_machines" {
21+
# source = "./GCP_MACHINES"
22+
# public_key_path = var.PUBLIC_KEY_PATH
23+
# PRIVATE_KEY_PATH = var.PRIVATE_KEY_PATH
24+
# region = "us-west1"
25+
# zone = "a"
26+
# name_format = local.name_format
27+
# GCP_COMPUTE_FILTER = ["UBUNTU_18_04_LTS", "UBUNTU_20_04_LTS", "UBUNTU_22_04_LTS", "RHEL_8", "CENTOS_8"]
28+
# CI = var.CI
29+
# PUBLIC_KEY = var.PUBLIC_KEY
3030

31-
providers = {
32-
google = google
33-
}
34-
}
31+
# providers = {
32+
# google = google
33+
# }
34+
# }
3535

3636
module "azure_machines" {
3737
source = "./AZURE_MACHINES"

Diff for: test_code/user_data/azure_windows.ps.tpl

-46
This file was deleted.

0 commit comments

Comments
 (0)