Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(packer): add vars and minor clean up #1611

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
34 changes: 27 additions & 7 deletions images/linux-amzn2/github_agent.linux.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ packer {
}
}

variable "action_runner_url" {
description = "The URL to the tarball of the action runner"
variable "runner_version" {
description = "The version (no v prefix) of the runner software to install https://github.com/actions/runner/releases"
type = string
default = "https://github.com/actions/runner/releases/download/v2.284.0/actions-runner-linux-x64-2.284.0.tar.gz"
default = "2.286.0"
}

variable "region" {
Expand All @@ -19,10 +19,30 @@ variable "region" {
default = "eu-west-1"
}

variable "security_group_id" {
description = "The ID of the security group Packer will associate with the builder to enable access"
type = string
default = null
}

variable "subnet_id" {
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"
type = string
default = null
}

variable "instance_type" {
description = "The instance type Packer will use for the builder"
type = string
default = "m3.medium"
}

source "amazon-ebs" "githubrunner" {
ami_name = "github-runner-amzn2-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = "m3.medium"
region = var.region
ami_name = "github-runner-amzn2-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
instance_type = var.instance_type
region = var.region
security_group_id = var.security_group_id
subnet_id = var.subnet_id
source_ami_filter {
filters = {
name = "amzn2-ami-hvm-2.*-x86_64-ebs"
Expand Down Expand Up @@ -60,7 +80,7 @@ build {

provisioner "shell" {
environment_vars = [
"RUNNER_TARBALL_URL=${var.action_runner_url}"
"RUNNER_TARBALL_URL=https://github.com/actions/runner/releases/download/v${var.runner_version}/actions-runner-linux-x64-${var.runner_version}.tar.gz"
]
inline = [templatefile("../install-runner.sh", {
install_runner = templatefile("../../modules/runners/templates/install-runner.sh", {
Expand Down
2 changes: 1 addition & 1 deletion modules/runners/templates/install-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ file_name="actions-runner.tar.gz"

echo "Creating actions-runner directory for the GH Action installtion"
cd /opt/
mkdir actions-runner && cd actions-runner
sudo mkdir actions-runner && sudo chown -R "$(whoami)" actions-runner && cd actions-runner
ScottGuymer marked this conversation as resolved.
Show resolved Hide resolved

if [[ -n "$RUNNER_TARBALL_URL" ]]; then
echo "Downloading the GH Action runner from $RUNNER_TARBALL_URL to $file_name"
Expand Down