Skip to content

Commit 5829fa3

Browse files
authored
Update windows core 2022 packerfile to reflect 2019s changes
1 parent 445a5d5 commit 5829fa3

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

images/windows-core-2022/github_agent.windows.pkr.hcl

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ variable "region" {
1818
default = "eu-west-1"
1919
}
2020

21+
variable "aws_account_number" {
22+
description = "The AWS account number"
23+
type = string
24+
default = ""
25+
}
26+
27+
variable "aws_region_mirror_list" {
28+
description = "The list of regions to mirror the AMI to"
29+
type = list(string)
30+
default = ["eu-west-1"]
31+
}
32+
33+
variable "instance_type" {
34+
description = "The instance type Packer will use for the builder"
35+
type = string
36+
default = "c7i-flex.xlarge"
37+
}
38+
2139
variable "security_group_id" {
2240
description = "The ID of the security group Packer will associate with the builder to enable access"
2341
type = string
@@ -30,11 +48,6 @@ variable "subnet_id" {
3048
default = null
3149
}
3250

33-
variable "root_volume_size_gb" {
34-
type = number
35-
default = 30
36-
}
37-
3851
variable "ebs_delete_on_termination" {
3952
description = "Indicates whether the EBS volume is deleted on instance termination."
4053
type = bool
@@ -72,15 +85,24 @@ locals {
7285
}
7386

7487
source "amazon-ebs" "githubrunner" {
75-
ami_name = "github-runner-windows-core-2022-${formatdate("YYYYMMDDhhmm", timestamp())}"
76-
communicator = "winrm"
77-
instance_type = "m4.xlarge"
88+
ami_name = "github-runner-windows-core-2022-${formatdate("YYYYMMDDhhmm", timestamp())}"
89+
ami_users = [ var.aws_account_number ]
90+
ami_regions = var.aws_region_mirror_list
91+
ami_description = "GitHub Actions runner AMI Windows Core 2019 Pro Video"
92+
93+
instance_type = var.instance_type
7894
region = var.region
7995
security_group_id = var.security_group_id
8096
subnet_id = var.subnet_id
8197
associate_public_ip_address = var.associate_public_ip_address
8298
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
8399

100+
user_data_file = "../setup-ssh.ps1"
101+
communicator = "ssh"
102+
ssh_username = "Administrator"
103+
ssh_file_transfer_method = "sftp"
104+
ssh_timeout = "15m"
105+
84106
source_ami_filter {
85107
filters = {
86108
name = "Windows_Server-2022-English-Full-ECS_Optimized-*"
@@ -90,20 +112,16 @@ source "amazon-ebs" "githubrunner" {
90112
most_recent = true
91113
owners = ["amazon"]
92114
}
115+
93116
tags = {
94117
OS_Version = "windows-core-2022"
95118
Release = "Latest"
96119
Base_AMI_Name = "{{ .SourceAMIName }}"
97120
}
98-
user_data_file = "./bootstrap_win.ps1"
99-
winrm_insecure = true
100-
winrm_port = 5986
101-
winrm_use_ssl = true
102-
winrm_username = "Administrator"
103121

104122
launch_block_device_mappings {
105123
device_name = "/dev/sda1"
106-
volume_size = "${var.root_volume_size_gb}"
124+
volume_size = 100
107125
delete_on_termination = "${var.ebs_delete_on_termination}"
108126
}
109127
}
@@ -116,7 +134,7 @@ build {
116134

117135
provisioner "file" {
118136
content = templatefile("../start-runner.ps1", {
119-
start_runner = templatefile("../../modules/runners/templates/start-runner.ps1", {})
137+
start_runner = templatefile("../../templates/start-runner.ps1", {})
120138
})
121139
destination = "C:\\start-runner.ps1"
122140
}
@@ -128,6 +146,12 @@ build {
128146
})
129147
], var.custom_shell_commands)
130148
}
149+
150+
provisioner "windows-restart" {
151+
restart_check_command = "powershell -command \"& {Write-Output 'Restarted!'}\""
152+
restart_timeout = "5m"
153+
}
154+
131155
post-processor "manifest" {
132156
output = "manifest.json"
133157
strip_path = true

0 commit comments

Comments
 (0)