@@ -7,10 +7,10 @@ packer {
7
7
}
8
8
}
9
9
10
- variable "action_runner_url " {
11
- description = " The URL to the tarball of the action runner"
10
+ variable "runner_version " {
11
+ description = " The version (no v prefix) of the runner software to install https://github.com/actions/ runner/releases "
12
12
type = string
13
- default = " https://github.com/actions/runner/releases/download/v2.284.0/actions-runner-linux-x64-2.284.0.tar.gz "
13
+ default = " 2.286.0 "
14
14
}
15
15
16
16
variable "region" {
@@ -19,10 +19,41 @@ variable "region" {
19
19
default = " eu-west-1"
20
20
}
21
21
22
+ variable "security_group_id" {
23
+ description = " The ID of the security group Packer will associate with the builder to enable access"
24
+ type = string
25
+ default = null
26
+ }
27
+
28
+ variable "subnet_id" {
29
+ 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"
30
+ type = string
31
+ default = null
32
+ }
33
+
34
+ variable "instance_type" {
35
+ description = " The instance type Packer will use for the builder"
36
+ type = string
37
+ default = " m3.medium"
38
+ }
39
+
40
+ variable "root_volume_size_gb" {
41
+ type = number
42
+ default = 8
43
+ }
44
+
45
+ variable "tags" {
46
+ description = " Additional tags to add globally"
47
+ type = map (string )
48
+ default = {}
49
+ }
50
+
22
51
source "amazon-ebs" "githubrunner" {
23
- ami_name = " github-runner-amzn2-x86_64-${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
24
- instance_type = " m3.medium"
25
- region = var. region
52
+ ami_name = " github-runner-amzn2-x86_64-${ formatdate (" YYYYMMDDhhmm" , timestamp ())} "
53
+ instance_type = var. instance_type
54
+ region = var. region
55
+ security_group_id = var. security_group_id
56
+ subnet_id = var. subnet_id
26
57
source_ami_filter {
27
58
filters = {
28
59
name = " amzn2-ami-hvm-2.*-x86_64-ebs"
@@ -33,10 +64,18 @@ source "amazon-ebs" "githubrunner" {
33
64
owners = [" 137112412989" ]
34
65
}
35
66
ssh_username = " ec2-user"
36
- tags = {
37
- OS_Version = " amzn2"
38
- Release = " Latest"
39
- Base_AMI_Name = " {{ .SourceAMIName }}"
67
+ tags = merge (
68
+ var. tags ,
69
+ {
70
+ OS_Version = " amzn2"
71
+ Release = " Latest"
72
+ Base_AMI_Name = " {{ .SourceAMIName }}"
73
+ })
74
+
75
+ launch_block_device_mappings {
76
+ device_name = " /dev/xvda"
77
+ volume_size = " ${ var . root_volume_size_gb } "
78
+ volume_type = " gp3"
40
79
}
41
80
}
42
81
@@ -58,16 +97,24 @@ build {
58
97
]
59
98
}
60
99
61
- provisioner "shell" {
62
- environment_vars = [
63
- " RUNNER_TARBALL_URL=${ var . action_runner_url } "
64
- ]
65
- inline = [templatefile (" ../install-runner.sh" , {
100
+ provisioner "file" {
101
+ content = templatefile (" ../install-runner.sh" , {
66
102
install_runner = templatefile (" ../../modules/runners/templates/install-runner.sh" , {
67
103
ARM_PATCH = " "
68
104
S3_LOCATION_RUNNER_DISTRIBUTION = " "
69
105
})
70
- })]
106
+ })
107
+ destination = " /tmp/install-runner.sh"
108
+ }
109
+
110
+ provisioner "shell" {
111
+ environment_vars = [
112
+ " RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${ var . runner_version } /actions-runner-linux-x64-${ var . runner_version } .tar.gz"
113
+ ]
114
+ inline = [
115
+ " sudo chmod +x /tmp/install-runner.sh" ,
116
+ " sudo RUNNER_TARBALL_URL=$RUNNER_TARBALL_URL /tmp/install-runner.sh"
117
+ ]
71
118
}
72
119
73
120
provisioner "file" {
0 commit comments