github.com/hernad/nomad@v1.6.112/e2e/terraform/packer/ubuntu-jammy-amd64.pkr.hcl (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  variable "build_sha" {
     5    type        = string
     6    description = "the revision of the packer scripts building this image"
     7  }
     8  
     9  locals {
    10    timestamp = regex_replace(timestamp(), "[- TZ:]", "")
    11    distro    = "ubuntu-jammy-22.04-amd64-server-*"
    12    version   = "v3"
    13  }
    14  
    15  source "amazon-ebs" "latest_ubuntu_jammy" {
    16    ami_name             = "nomad-e2e-${local.version}-ubuntu-jammy-amd64-${local.timestamp}"
    17    iam_instance_profile = "packer_build" // defined in nomad-e2e repo
    18    instance_type        = "t3a.medium"
    19    region               = "us-east-1"
    20    ssh_username         = "ubuntu"
    21    ssh_interface        = "public_ip"
    22  
    23    source_ami_filter {
    24      filters = {
    25        architecture                       = "x86_64"
    26        "block-device-mapping.volume-type" = "gp2"
    27        name                               = "ubuntu/images/hvm-ssd/${local.distro}"
    28        root-device-type                   = "ebs"
    29        virtualization-type                = "hvm"
    30      }
    31      most_recent = true
    32      owners      = ["099720109477"] // Canonical
    33    }
    34  
    35    tags = {
    36      OS         = "Ubuntu"
    37      Version    = "Jammy"
    38      BuilderSha = var.build_sha
    39    }
    40  }
    41  
    42  build {
    43    sources = ["source.amazon-ebs.latest_ubuntu_jammy"]
    44  
    45    provisioner "file" {
    46      destination = "/tmp/linux"
    47      source      = "./ubuntu-jammy-amd64"
    48    }
    49  
    50    // cloud-init modifies the apt sources, so we need to wait
    51    // before running our setup
    52    provisioner "shell-local" {
    53      inline = ["sleep 30"]
    54    }
    55  
    56    provisioner "shell" {
    57      script = "./ubuntu-jammy-amd64/setup.sh"
    58    }
    59  }