open-nomad/e2e/terraform/packer/ubuntu-bionic-amd64.pkr.hcl
Tim Gross 9f05d62338
E2E with HCP Consul/Vault (#12267)
Use HCP Consul and HCP Vault for the Consul and Vault clusters used in E2E testing. This has the following benefits:

* Without the need to support mTLS bootstrapping for Consul and Vault, we can simplify the mTLS configuration by leaning on Terraform instead of janky bash shell scripting.
* Vault bootstrapping is no longer required, so we can eliminate even more janky shell scripting
* Our E2E exercises HCP, which is important to us as an organization
* With the reduction in configurability, we can simplify the Terraform configuration and drop the complicated `provision.sh`/`provision.ps1` scripts we were using previously. We can template Nomad configuration files and upload them with the `file` provisioner.
* Packer builds for Linux and Windows become much simpler.

tl;dr way less janky shell scripting!
2022-03-18 09:27:28 -04:00

57 lines
1.5 KiB
HCL

variable "build_sha" {
type = string
description = "the revision of the packer scripts building this image"
}
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
distro = "ubuntu-bionic-18.04-amd64-server-*"
version = "v3"
}
source "amazon-ebs" "latest_ubuntu_bionic" {
ami_name = "nomad-e2e-${local.version}-ubuntu-bionic-amd64-${local.timestamp}"
iam_instance_profile = "packer_build" // defined in nomad-e2e repo
instance_type = "t2.medium"
region = "us-east-1"
ssh_username = "ubuntu"
ssh_interface = "public_ip"
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 = {
OS = "Ubuntu"
Version = "Bionic"
BuilderSha = var.build_sha
}
}
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"
}
}