Skip to content

Commit cdcb737

Browse files
committed
Adding Ubuntu 24.04
1 parent ffab841 commit cdcb737

File tree

12 files changed

+747
-3
lines changed

12 files changed

+747
-3
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
matcherConfig:
2+
exactMatch: true
3+
labelMatchers:
4+
# - [ self-hosted, linux, arm64, ubuntu-latest-aws ]
5+
- [ self-hosted, linux, arm64, ubuntu-24.04-aws ]
6+
fifo: true
7+
redrive_build_queue:
8+
enabled: false
9+
maxReceiveCount: null
10+
runner_config:
11+
create_service_linked_role_spot: true
12+
enable_ephemeral_runners: true
13+
instance_target_capacity_type: "on-demand"
14+
enable_userdata: false
15+
runner_os: linux
16+
runner_architecture: arm64
17+
# runner_extra_labels: "ubuntu-latest-aws,ubuntu-24.04-aws"
18+
runner_extra_labels: "ubuntu-24.04-aws"
19+
runner_run_as: ubuntu
20+
runner_name_prefix: ubuntu-2404-arm64_
21+
enable_ssm_on_runners: true
22+
credit_specification: standard
23+
instance_types:
24+
- t4g.large
25+
- c6g.large
26+
runners_maximum_count: 50
27+
delay_webhook_event: 0
28+
scale_down_schedule_expression: cron(* * * * ? *)
29+
# userdata_template: ./templates/user-data.sh
30+
ami_owners: [ "047402373783" ]
31+
ami_filter: { 'name': ['github-runner-ubuntu-noble-arm64-202404261611'] }
32+
block_device_mappings:
33+
- device_name: /dev/sda1
34+
delete_on_termination: true
35+
volume_type: gp3
36+
volume_size: 50
37+
encrypted: true
38+
iops: null
39+
throughput: null
40+
kms_key_id: null
41+
snapshot_id: null
42+
runner_log_files:
43+
- log_group_name: syslog
44+
prefix_log_group: true
45+
file_path: /var/log/syslog
46+
log_stream_name: "{instance_id}"
47+
- log_group_name: user_data
48+
prefix_log_group: true
49+
file_path: /var/log/user-data.log
50+
log_stream_name: "{instance_id}/user_data"
51+
- log_group_name: runner
52+
prefix_log_group: true
53+
file_path: /opt/actions-runner/_diag/Runner_**.log
54+
log_stream_name: "{instance_id}/runner"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
matcherConfig:
2+
exactMatch: true
3+
labelMatchers:
4+
# - [ self-hosted, linux, x64, ubuntu-latest-aws ]
5+
- [ self-hosted, linux, x64, ubuntu-24.04-aws ]
6+
fifo: true
7+
redrive_build_queue:
8+
enabled: false
9+
maxReceiveCount: null
10+
runner_config:
11+
create_service_linked_role_spot: true
12+
enable_ephemeral_runners: true
13+
instance_target_capacity_type: "on-demand"
14+
enable_userdata: false
15+
runner_os: linux
16+
runner_architecture: x64
17+
# runner_extra_labels: "ubuntu-latest-aws,ubuntu-24.04-aws"
18+
runner_extra_labels: "ubuntu-24.04-aws"
19+
runner_run_as: ubuntu
20+
runner_name_prefix: ubuntu-2404-x64_
21+
enable_ssm_on_runners: true
22+
credit_specification: standard
23+
instance_types:
24+
- m5ad.large
25+
- m5a.large
26+
runners_maximum_count: 200
27+
delay_webhook_event: 0
28+
scale_down_schedule_expression: cron(* * * * ? *)
29+
# userdata_template: ./templates/user-data.sh
30+
ami_owners: [ "047402373783" ]
31+
ami_filter: { 'name': ['github-runner-ubuntu-noble-amd64-202404261624'] }
32+
block_device_mappings:
33+
- device_name: /dev/sda1
34+
delete_on_termination: true
35+
volume_type: gp3
36+
volume_size: 50
37+
encrypted: true
38+
iops: null
39+
throughput: null
40+
kms_key_id: null
41+
snapshot_id: null
42+
runner_log_files:
43+
- log_group_name: syslog
44+
prefix_log_group: true
45+
file_path: /var/log/syslog
46+
log_stream_name: "{instance_id}"
47+
- log_group_name: user_data
48+
prefix_log_group: true
49+
file_path: /var/log/user-data.log
50+
log_stream_name: "{instance_id}/user_data"
51+
- log_group_name: runner
52+
prefix_log_group: true
53+
file_path: /opt/actions-runner/_diag/Runner_**.log
54+
log_stream_name: "{instance_id}/runner"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
ssh_keypair_name = "tagr-us-west-2"
3+
ssh_private_key_file = "/home/sam/work/cppalliance/aws/boost.v2.account/tagr-us-west-2.pem"
4+
disable_docker_registry = true
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
packer {
2+
required_plugins {
3+
amazon = {
4+
version = ">= 0.0.2"
5+
source = "github.com/hashicorp/amazon"
6+
}
7+
}
8+
}
9+
10+
variable "ssh_keypair_name" {
11+
description = "SSH keypair name"
12+
type = string
13+
default = null
14+
}
15+
16+
variable "ssh_private_key_file" {
17+
description = "SSH private key file"
18+
type = string
19+
default = null
20+
}
21+
22+
variable "disable_docker_registry" {
23+
description = "SSH private key file"
24+
type = string
25+
default = "false"
26+
}
27+
28+
variable "runner_version" {
29+
description = "The version (no v prefix) of the runner software to install https://github.com/actions/runner/releases. The latest release will be fetched from GitHub if not provided."
30+
default = null
31+
}
32+
33+
variable "region" {
34+
description = "The region to build the image in"
35+
type = string
36+
default = "eu-west-1"
37+
}
38+
39+
variable "security_group_id" {
40+
description = "The ID of the security group Packer will associate with the builder to enable access"
41+
type = string
42+
default = null
43+
}
44+
45+
variable "subnet_id" {
46+
description = "If using VPC, the ID of the subnet, such as subnet-12345def, where Packer will launch the EC2 instance. This field is required if you are using an non-default VPC"
47+
type = string
48+
default = null
49+
}
50+
51+
variable "associate_public_ip_address" {
52+
description = "If using a non-default VPC, there is no public IP address assigned to the EC2 instance. If you specified a public subnet, you probably want to set this to true. Otherwise the EC2 instance won't have access to the internet"
53+
type = string
54+
default = null
55+
}
56+
57+
variable "instance_type" {
58+
description = "The instance type Packer will use for the builder"
59+
type = string
60+
default = "t4g.small"
61+
}
62+
63+
variable "root_volume_size_gb" {
64+
type = number
65+
default = 8
66+
}
67+
68+
variable "ebs_delete_on_termination" {
69+
description = "Indicates whether the EBS volume is deleted on instance termination."
70+
type = bool
71+
default = true
72+
}
73+
74+
variable "global_tags" {
75+
description = "Tags to apply to everything"
76+
type = map(string)
77+
default = {}
78+
}
79+
80+
variable "ami_tags" {
81+
description = "Tags to apply to the AMI"
82+
type = map(string)
83+
default = {}
84+
}
85+
86+
variable "snapshot_tags" {
87+
description = "Tags to apply to the snapshot"
88+
type = map(string)
89+
default = {}
90+
}
91+
92+
variable "custom_shell_commands" {
93+
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
94+
type = list(string)
95+
default = []
96+
}
97+
98+
data "http" github_runner_release_json {
99+
url = "https://api.github.com/repos/actions/runner/releases/latest"
100+
request_headers = {
101+
Accept = "application/vnd.github+json"
102+
X-GitHub-Api-Version : "2022-11-28"
103+
}
104+
}
105+
106+
locals {
107+
runner_version = coalesce(var.runner_version, trimprefix(jsondecode(data.http.github_runner_release_json.body).tag_name, "v"))
108+
}
109+
110+
source "amazon-ebs" "githubrunner" {
111+
ami_name = "github-runner-ubuntu-noble-arm64-${formatdate("YYYYMMDDhhmm", timestamp())}"
112+
instance_type = var.instance_type
113+
region = var.region
114+
security_group_id = var.security_group_id
115+
subnet_id = var.subnet_id
116+
associate_public_ip_address = var.associate_public_ip_address
117+
118+
source_ami_filter {
119+
filters = {
120+
name = "*/ubuntu-noble-24.04-arm64-server-*"
121+
root-device-type = "ebs"
122+
virtualization-type = "hvm"
123+
}
124+
most_recent = true
125+
owners = ["099720109477"]
126+
}
127+
ssh_username = "ubuntu"
128+
tags = merge(
129+
var.global_tags,
130+
var.ami_tags,
131+
{
132+
OS_Version = "ubuntu-noble"
133+
Release = "Latest"
134+
Base_AMI_Name = "{{ .SourceAMIName }}"
135+
})
136+
snapshot_tags = merge(
137+
var.global_tags,
138+
var.snapshot_tags,
139+
)
140+
141+
launch_block_device_mappings {
142+
device_name = "/dev/sda1"
143+
volume_size = "${var.root_volume_size_gb}"
144+
volume_type = "gp3"
145+
delete_on_termination = "${var.ebs_delete_on_termination}"
146+
}
147+
}
148+
149+
build {
150+
name = "githubactions-runner"
151+
sources = [
152+
"source.amazon-ebs.githubrunner"
153+
]
154+
provisioner "shell" {
155+
environment_vars = [
156+
"DEBIAN_FRONTEND=noninteractive",
157+
"DISABLE_DOCKER_REGISTRY=${var.disable_docker_registry}"
158+
]
159+
inline = concat([
160+
"sudo cloud-init status --wait",
161+
"sudo apt-get update",
162+
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
163+
"sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg",
164+
"echo deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null",
165+
"sudo apt-get -y update",
166+
"sudo apt-get -y install docker-ce docker-ce-cli containerd.io jq git unzip build-essential",
167+
"sudo systemctl enable containerd.service",
168+
"sudo service docker start",
169+
"sudo usermod -a -G docker ubuntu",
170+
"sudo curl -f https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb -o amazon-cloudwatch-agent.deb",
171+
"sudo dpkg -i amazon-cloudwatch-agent.deb",
172+
"sudo systemctl restart amazon-cloudwatch-agent",
173+
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o awscliv2.zip",
174+
"unzip awscliv2.zip",
175+
"sudo ./aws/install",
176+
], var.custom_shell_commands)
177+
}
178+
179+
provisioner "file" {
180+
content = templatefile("../install-runner.sh", {
181+
install_runner = templatefile("../../modules/runners/templates/install-runner.sh", {
182+
ARM_PATCH = ""
183+
S3_LOCATION_RUNNER_DISTRIBUTION = ""
184+
RUNNER_ARCHITECTURE = "arm64"
185+
})
186+
})
187+
destination = "/tmp/install-runner.sh"
188+
}
189+
190+
provisioner "shell" {
191+
environment_vars = [
192+
"RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${local.runner_version}/actions-runner-linux-arm64-${local.runner_version}.tar.gz"
193+
]
194+
inline = [
195+
"sudo chmod +x /tmp/install-runner.sh",
196+
"echo ubuntu | tee -a /tmp/install-user.txt",
197+
"sudo RUNNER_ARCHITECTURE=arm64 RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh",
198+
"echo ImageOS=ubuntu24 | tee -a /opt/actions-runner/.env"
199+
]
200+
}
201+
202+
provisioner "file" {
203+
content = templatefile("../start-runner.sh", {
204+
start_runner = templatefile("../../modules/runners/templates/start-runner.sh", { metadata_tags = "enabled" })
205+
})
206+
destination = "/tmp/start-runner.sh"
207+
}
208+
209+
provisioner "shell" {
210+
inline = [
211+
"sudo mv /tmp/start-runner.sh /var/lib/cloud/scripts/per-boot/start-runner.sh",
212+
"sudo chmod +x /var/lib/cloud/scripts/per-boot/start-runner.sh",
213+
]
214+
}
215+
216+
post-processor "manifest" {
217+
output = "manifest.json"
218+
strip_path = true
219+
}
220+
221+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"builds": [
3+
{
4+
"name": "githubrunner",
5+
"builder_type": "amazon-ebs",
6+
"build_time": 1691075805,
7+
"files": null,
8+
"artifact_id": "us-west-2:ami-0f8b73d040984706b",
9+
"packer_run_uuid": "ad7a1fc3-de05-8755-7c02-1dc23359ce06",
10+
"custom_data": null
11+
},
12+
{
13+
"name": "githubrunner",
14+
"builder_type": "amazon-ebs",
15+
"build_time": 1714148589,
16+
"files": null,
17+
"artifact_id": "us-west-2:ami-0862bbc2ea5687509",
18+
"packer_run_uuid": "83651078-3e85-1e91-25d5-983577e32521",
19+
"custom_data": null
20+
}
21+
],
22+
"last_run_uuid": "83651078-3e85-1e91-25d5-983577e32521"
23+
}

0 commit comments

Comments
 (0)