-
Notifications
You must be signed in to change notification settings - Fork 0
/
packer-self-hosted-runner.pkr.hcl
53 lines (46 loc) · 1.2 KB
/
packer-self-hosted-runner.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
variable "ssh_user" {
type = string
default = "ubuntu"
}
variable "gh_runner_config_token" {
type = string
sensitive = true
}
variable "gh_runner_env_label" {
type = string
}
locals {
timestamp = formatdate("YYYYMMDD", timestamp())
}
source "amazon-ebs" "ubuntu" {
ami_name = "GitHub-self-hosted-runner-${var.gh_runner_env_label}-${local.timestamp}"
instance_type = "t3.micro"
region = "eu-central-1"
ssh_username = var.ssh_user
source_ami_filter {
filters = {
name = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
architecture = "x86_64"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
}
build {
sources = ["source.amazon-ebs.ubuntu"]
provisioner "ansible" {
playbook_file = "./ansible/ansible-self-hosted-runner.yaml"
user = var.ssh_user
use_proxy = false
extra_arguments = [
"--extra-vars",
"gh_runner_config_token=${var.gh_runner_config_token} gh_runner_env_label=${var.gh_runner_env_label}"
]
}
post-processor "manifest" {
output = "manifest.json"
strip_path = true
}
}