Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions images/linux-amzn2/github_agent.linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ variable "snapshot_tags" {
default = {}
}

variable "custom_shell_commands" {
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
type = list(string)
default = []
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-amzn2-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = var.instance_type
Expand Down Expand Up @@ -118,15 +124,15 @@ build {
]
provisioner "shell" {
environment_vars = []
inline = [
inline = concat([
"sudo yum update -y",
"sudo yum install -y amazon-cloudwatch-agent curl jq git",
"sudo amazon-linux-extras install docker",
"sudo systemctl enable docker.service",
"sudo systemctl enable containerd.service",
"sudo service docker start",
"sudo usermod -a -G docker ec2-user",
]
], var.custom_shell_commands)
}

provisioner "file" {
Expand Down
10 changes: 8 additions & 2 deletions images/ubuntu-focal/github_agent.ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ variable "snapshot_tags" {
default = {}
}

variable "custom_shell_commands" {
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
type = list(string)
default = []
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-ubuntu-focal-amd64-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = var.instance_type
Expand Down Expand Up @@ -120,7 +126,7 @@ build {
environment_vars = [
"DEBIAN_FRONTEND=noninteractive"
]
inline = [
inline = concat([
"sudo apt-get -y update",
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
"sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg",
Expand All @@ -136,7 +142,7 @@ build {
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip",
"unzip awscliv2.zip",
"sudo ./aws/install",
]
], var.custom_shell_commands)
}

provisioner "file" {
Expand Down
14 changes: 11 additions & 3 deletions images/windows-core-2019/github_agent.windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ variable "associate_public_ip_address" {
default = null
}

variable "custom_shell_commands" {
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
type = list(string)
default = []
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-windows-core-2019-${formatdate("YYYYMMDDhhmm", timestamp())}"
communicator = "winrm"
Expand Down Expand Up @@ -78,8 +84,10 @@ build {
}

provisioner "powershell" {
inline = [templatefile("./windows-provisioner.ps1", {
action_runner_url = var.action_runner_url
})]
inline = concat([
templatefile("./windows-provisioner.ps1", {
action_runner_url = var.action_runner_url
})
], var.custom_shell_commands)
}
}