Skip to content

Commit 8647e3f

Browse files
authored
chore(e2e): Add support for Windows Server 2016 (#5994)
* chore: Fix spacing * chore(e2e): Add support for windows server 2016 * fix(e2e): Pass region into worker module * CR: Rename scenario * CR: enos fmt * CR: Add username to enos vpc * CR: Add vault environment variables
1 parent 91a143b commit 8647e3f

File tree

8 files changed

+42
-18
lines changed

8 files changed

+42
-18
lines changed

enos/enos-scenario-e2e-aws-windows.hcl renamed to enos/enos-scenario-e2e-aws-rdp-base.hcl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Copyright (c) HashiCorp, Inc.
22
# SPDX-License-Identifier: BUSL-1.1
33

4-
scenario "e2e_aws_windows" {
4+
# This scenario creates a complete end-to-end test environment for Boundary to
5+
# test RDP functionality. It includes a Windows client, a Boundary controller
6+
# and worker, a domain controller, a member server, and another member server
7+
# with a worker running on it.
8+
scenario "e2e_aws_rdp_base" {
59
terraform_cli = terraform_cli.default
610
terraform = terraform.default
711
providers = [
@@ -10,8 +14,11 @@ scenario "e2e_aws_windows" {
1014
]
1115

1216
matrix {
13-
builder = ["local", "crt"]
14-
client = ["win10", "win11"]
17+
builder = ["local", "crt"]
18+
client = ["win10", "win11"]
19+
# Windows Server 2016 does not support OpenSSH, but it's relied on for some
20+
# parts of setup. If 2016 is selected, the member server will be created as
21+
# 2016, but the domain controller and worker will be 2019.
1522
rdp_server = ["2016", "2019", "2022", "2025"]
1623
}
1724

@@ -150,7 +157,7 @@ scenario "e2e_aws_windows" {
150157

151158
variables {
152159
vpc_id = step.create_base_infra.vpc_id
153-
server_version = matrix.rdp_server
160+
server_version = matrix.rdp_server == "2016" ? "2019" : matrix.rdp_server
154161
}
155162
}
156163

@@ -233,7 +240,7 @@ scenario "e2e_aws_windows" {
233240

234241
variables {
235242
vpc_id = step.create_base_infra.vpc_id
236-
server_version = matrix.rdp_server
243+
server_version = matrix.rdp_server == "2016" ? "2019" : matrix.rdp_server
237244
boundary_cli_zip_path = step.build_boundary_windows.artifact_path
238245
kms_key_arn = step.create_base_infra.kms_key_arn
239246
controller_ip = step.create_boundary_cluster.public_controller_addresses[0]
@@ -245,6 +252,7 @@ scenario "e2e_aws_windows" {
245252
domain_admin_password = step.create_rdp_domain_controller.password
246253
domain_controller_private_key = step.create_rdp_domain_controller.ssh_private_key
247254
domain_controller_sec_group_id_list = step.create_rdp_domain_controller.security_group_id_list
255+
aws_region = var.aws_region
248256
}
249257
}
250258

@@ -303,6 +311,9 @@ scenario "e2e_aws_windows" {
303311
client_username = step.create_windows_client.test_username
304312
client_password = step.create_windows_client.test_password
305313
client_test_dir = step.create_windows_client.test_dir
314+
vault_addr_public = step.create_vault_cluster.instance_public_ips_ipv4[0]
315+
vault_addr_private = step.create_vault_cluster.instance_private_ips[0]
316+
vault_root_token = step.create_vault_cluster.vault_root_token
306317
}
307318
}
308319

@@ -389,4 +400,4 @@ scenario "e2e_aws_windows" {
389400
output "windows_worker_private_ip" {
390401
value = step.create_windows_worker.private_ip
391402
}
392-
}
403+
}

enos/enos-scenario-e2e-aws-rdp-target.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) HashiCorp, Inc.
22
# SPDX-License-Identifier: BUSL-1.1
33

4+
# This scenario creates a single Windows ec2 instance that acts as a domain
5+
# controller. This can be used as an RDP target for boundary.
46
scenario "e2e_aws_rdp_target" {
57
terraform_cli = terraform_cli.default
68
terraform = terraform.default

enos/modules/aws_rdp_member_server/main.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ resource "aws_instance" "member_server" {
6161

6262
user_data = <<EOF
6363
<powershell>
64+
%{if var.server_version != "2016"~}
6465
# set variables for retry loops
6566
$timeout = 300
6667
$interval = 30
6768
6869
# Set up SSH so we can remotely manage the instance
6970
## Install OpenSSH Server and Client
70-
# Loop to make sure that SSH installs correctly
71-
$elapsed = 0
71+
# Loop to make sure that SSH installs correctly
72+
$elapsed = 0
7273
do {
7374
try {
7475
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
@@ -129,6 +130,7 @@ resource "aws_instance" "member_server" {
129130
130131
## Open the firewall for SSH connections
131132
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
133+
%{endif~}
132134
133135
# Adds member server to the domain
134136
[int]$intix = Get-NetAdapter | % { Process { If ( $_.Status -eq "up" ) { $_.ifIndex } }}
@@ -160,7 +162,7 @@ ${var.domain_admin_password}
160162
Write-Host "Resovling domain after 5 minutes. Exiting."
161163
exit 1
162164
}
163-
} while ($true)
165+
} while ($true)
164166
165167
#logging to troubleshoot domain issues
166168
Resolve-DnsName -Name "${var.active_directory_domain}" -Server "${var.domain_controller_ip}" -ErrorAction SilentlyContinue
@@ -222,13 +224,15 @@ resource "time_sleep" "wait_2_minutes" {
222224
# BatchMode=Yes to prevent SSH from prompting for a password to ensure that we
223225
# can just SSH using the private key
224226
resource "enos_local_exec" "wait_for_ssh" {
227+
count = var.server_version != "2016" ? 1 : 0
225228
depends_on = [time_sleep.wait_2_minutes]
226229
inline = ["timeout 600s bash -c 'until ssh -i ${local.private_key} -o BatchMode=Yes -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no Administrator@${aws_instance.member_server.public_ip} \"echo ready\"; do sleep 10; done'"]
227230
}
228231

229232
# Retrieve the domain hostname of the member server, which will be used in
230233
# Kerberos
231234
resource "enos_local_exec" "get_hostname" {
235+
count = var.server_version != "2016" ? 1 : 0
232236
depends_on = [
233237
enos_local_exec.wait_for_ssh,
234238
]

enos/modules/aws_rdp_member_server/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ output "password" {
2929
}
3030

3131
output "domain_hostname" {
32-
description = "The hostname of the domain controller"
33-
value = trimspace(enos_local_exec.get_hostname.stdout)
32+
description = "The hostname of the member server"
33+
value = var.server_version != "2016" ? trimspace(enos_local_exec.get_hostname[0].stdout) : ""
3434
}

enos/modules/aws_rdp_member_server_with_worker/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ resource "aws_instance" "worker" {
9393
9494
# Set up SSH so we can remotely manage the instance
9595
## Install OpenSSH Server and Client
96-
# Loop to make sure that SSH installs correctly
97-
$elapsed = 0
96+
# Loop to make sure that SSH installs correctly
97+
$elapsed = 0
9898
do {
9999
try {
100100
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
@@ -158,14 +158,14 @@ resource "aws_instance" "worker" {
158158
New-NetFirewallRule -Name boundary_in -DisplayName 'Boundary inbound' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 9202
159159
New-NetFirewallRule -Name boundary_out -DisplayName 'Boundary outbound' -Enabled True -Direction Outbound -Protocol TCP -Action Allow -LocalPort 9202
160160
161-
## Add computer to the domain
161+
# Add computer to the domain
162162
[int]$intix = Get-NetAdapter | % { Process { If ( $_.Status -eq "up" ) { $_.ifIndex } }}
163163
Set-DNSClientServerAddress -interfaceIndex $intix -ServerAddresses ("${var.domain_controller_ip}","127.0.0.1")
164164
$here_string_password = @'
165165
${var.domain_admin_password}
166166
'@
167167
$password = ConvertTo-SecureString $here_string_password -AsPlainText -Force
168-
$username = "${local.domain_sld}\Administrator"
168+
$username = "${local.domain_sld}\Administrator"
169169
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
170170
171171
# check that domain can be reached
@@ -184,7 +184,7 @@ ${var.domain_admin_password}
184184
Write-Host "Resolving domain after 5 minutes. Exiting."
185185
exit 1
186186
}
187-
} while ($true)
187+
} while ($true)
188188
189189
#logging to troubleshoot domain issues
190190
Resolve-DnsName -Name "${var.active_directory_domain}" -Server "${var.domain_controller_ip}" -ErrorAction SilentlyContinue

enos/modules/aws_rdp_member_server_with_worker/scripts/setup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ $command = "boundary server -config `"$configPath`" *> $jobLog"
2626
Register-ScheduledJob boundary -ScriptBlock ([ScriptBlock]::Create($command)) -Trigger $trigger
2727

2828
# Restart the computer to apply changes
29-
shutdown -r -t 10
29+
shutdown -r -t 10

enos/modules/aws_vault/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ output "instance_public_ips" {
1111
value = var.ip_version == "4" ? [for instance in aws_instance.vault_instance : instance.public_ip] : flatten([for instance in aws_instance.vault_instance : instance.ipv6_addresses])
1212
}
1313

14+
output "instance_public_ips_ipv4" {
15+
description = "Public IPv4 addresses of Vault instances"
16+
value = [for instance in aws_instance.vault_instance : instance.public_ip if instance.public_ip != null]
17+
}
18+
1419
output "instance_private_ips" {
1520
description = "Private IPs of Vault instances"
1621
value = [for instance in aws_instance.vault_instance : instance.private_ip]

enos/modules/aws_vpc_ipv6/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ variable "ip_version" {
7171
}
7272
}
7373

74+
data "aws_caller_identity" "current" {}
75+
7476
data "enos_environment" "localhost" {}
7577

7678
check "ipv6_connection" {
@@ -174,7 +176,7 @@ resource "aws_vpc" "vpc" {
174176
tags = merge(
175177
local.common_tags,
176178
{
177-
"Name" = var.name
179+
"Name" = "${var.name}-${split(":", data.aws_caller_identity.current.user_id)[1]}"
178180
},
179181
)
180182
}

0 commit comments

Comments
 (0)