2023-04-10 15:36:59 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2021-01-12 18:15:33 +00:00
|
|
|
variable "build_sha" {
|
|
|
|
type = string
|
|
|
|
description = "the revision of the packer scripts building this image"
|
|
|
|
}
|
|
|
|
|
2020-10-29 14:03:39 +00:00
|
|
|
locals {
|
|
|
|
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
|
|
|
distro = "ubuntu-bionic-18.04-amd64-server-*"
|
2022-03-18 13:27:28 +00:00
|
|
|
version = "v3"
|
2020-10-29 14:03:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source "amazon-ebs" "latest_ubuntu_bionic" {
|
2021-01-12 18:30:30 +00:00
|
|
|
ami_name = "nomad-e2e-${local.version}-ubuntu-bionic-amd64-${local.timestamp}"
|
2020-10-29 14:03:39 +00:00
|
|
|
iam_instance_profile = "packer_build" // defined in nomad-e2e repo
|
|
|
|
instance_type = "t2.medium"
|
|
|
|
region = "us-east-1"
|
|
|
|
ssh_username = "ubuntu"
|
2021-04-27 18:27:33 +00:00
|
|
|
ssh_interface = "public_ip"
|
2020-10-29 14:03:39 +00:00
|
|
|
|
|
|
|
source_ami_filter {
|
|
|
|
filters = {
|
|
|
|
architecture = "x86_64"
|
|
|
|
"block-device-mapping.volume-type" = "gp2"
|
|
|
|
name = "ubuntu/images/hvm-ssd/${local.distro}"
|
|
|
|
root-device-type = "ebs"
|
|
|
|
virtualization-type = "hvm"
|
|
|
|
}
|
|
|
|
most_recent = true
|
|
|
|
owners = ["099720109477"] // Canonical
|
|
|
|
}
|
|
|
|
|
|
|
|
tags = {
|
2021-01-12 18:15:33 +00:00
|
|
|
OS = "Ubuntu"
|
|
|
|
Version = "Bionic"
|
|
|
|
BuilderSha = var.build_sha
|
2020-10-29 14:03:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
sources = ["source.amazon-ebs.latest_ubuntu_bionic"]
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
destination = "/tmp/linux"
|
|
|
|
source = "./ubuntu-bionic-amd64"
|
|
|
|
}
|
|
|
|
|
|
|
|
// cloud-init modifies the apt sources, so we need to wait
|
|
|
|
// before running our setup
|
|
|
|
provisioner "shell-local" {
|
|
|
|
inline = ["sleep 30"]
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "shell" {
|
|
|
|
script = "./ubuntu-bionic-amd64/setup.sh"
|
|
|
|
}
|
|
|
|
}
|