github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/terraform/packer/ubuntu-jammy-amd64.pkr.hcl (about)

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