github.com/hashicorp/packer@v1.14.3/examples/hcl/linux/build.ubuntu.pkr.hcl (about)

     1  
     2  build {
     3    name = "ubuntu"
     4    description = <<EOF
     5  This build creates ubuntu images for ubuntu versions :
     6  * 16.04
     7  * 18.04
     8  For the following builders :
     9  * virtualbox-iso
    10  * parallels-iso
    11  * vmware-iso
    12  * qemu
    13  * vsphere-iso
    14  EOF
    15  
    16    // the common fields of the source blocks are defined in the
    17    // source.builder-type.pkr.hcl files, here we only set the fields specific to
    18    // the different versions of ubuntu.
    19    source "source.virtualbox-iso.base-ubuntu-amd64" {
    20      name                    = "16.04"
    21      iso_url                 = local.iso_url_ubuntu_1604
    22      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
    23      output_directory        = "virtualbox_iso_ubuntu_1604_amd64"
    24      boot_command            = local.ubuntu_1604_boot_command
    25      boot_wait               = "10s"
    26    }
    27  
    28    source "source.virtualbox-iso.base-ubuntu-amd64" {
    29      name                    = "18.04"
    30      iso_url                 = local.iso_url_ubuntu_1804
    31      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1804}"
    32      output_directory        = "virtualbox_iso_ubuntu_1804_amd64"
    33      boot_command            = local.ubuntu_1804_boot_command
    34      boot_wait               = "5s"
    35    }
    36  
    37    source "source.parallels-iso.base-ubuntu-amd64" {
    38      name                    = "16.04"
    39      iso_url                 = local.iso_url_ubuntu_1604
    40      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
    41      output_directory        = "parallels_iso_ubuntu_1604_amd64"
    42      boot_command            = local.ubuntu_1604_boot_command
    43    }
    44  
    45    source "source.parallels-iso.base-ubuntu-amd64" {
    46      name                    = "18.04"
    47      iso_url                 = local.iso_url_ubuntu_1804
    48      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1804}"
    49      output_directory        = "parallels_iso_ubuntu_1804_amd64"
    50      boot_command            = local.ubuntu_1804_boot_command
    51    }
    52  
    53    source "source.vmware-iso.base-ubuntu-amd64" {
    54      name                    = "16.04"
    55      iso_url                 = local.iso_url_ubuntu_1604
    56      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
    57      output_directory        = "vmware_iso_ubuntu_1604_amd64"
    58      boot_command            = local.ubuntu_1604_boot_command
    59    }
    60  
    61    source "source.vmware-vmx.base-ubuntu-amd64" {
    62      name        = "16.04"
    63      source_path = "vmware_iso_ubuntu_1604_amd64/packer-base-ubuntu-amd64.vmx"
    64    }
    65  
    66    source "source.vmware-iso.base-ubuntu-amd64" {
    67      name                    = "18.04"
    68      iso_url                 = local.iso_url_ubuntu_1804
    69      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1804}"
    70      output_directory        = "vmware_iso_ubuntu_1804_amd64"
    71      boot_command            = local.ubuntu_1804_boot_command
    72    }
    73  
    74    source "source.vmware-iso.esxi-base-ubuntu-amd64" {
    75      name                    = "16.04-from-esxi"
    76      iso_url                 = local.iso_url_ubuntu_1604
    77      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
    78      output_directory        = "vmware_iso_ubuntu_1604_amd64_from_esxi"
    79      boot_command            = local.ubuntu_1604_boot_command
    80    }
    81  
    82    source "source.qemu.base-ubuntu-amd64" {
    83      name                    = "16.04"
    84      iso_url                 = local.iso_url_ubuntu_1604
    85      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
    86      output_directory        = "qemu_iso_ubuntu_1604_amd64"
    87      boot_command            = local.ubuntu_1604_boot_command
    88    }
    89  
    90    source "source.qemu.base-ubuntu-amd64" {
    91      name                    = "18.04"
    92      iso_url                 = local.iso_url_ubuntu_1804
    93      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1804}"
    94      output_directory        = "qemu_iso_ubuntu_1804_amd64"
    95      boot_command            = local.ubuntu_1804_boot_command
    96    }
    97  
    98    source "source.vsphere-iso.base-ubuntu-amd64" {
    99      name                    = "16.04"
   100      vm_name                 = "ubuntu-16.04"
   101      iso_url                 = local.iso_url_ubuntu_1604
   102      iso_checksum            = "file:${local.iso_checksum_url_ubuntu_1604}"
   103    }
   104  
   105    provisioner "shell" {
   106      environment_vars  = [ "HOME_DIR=/home/vagrant" ]
   107      execute_command   = "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
   108      expect_disconnect = true
   109      // fileset will list files in etc/scripts sorted in an alphanumerical way.
   110      scripts           = fileset(".", "etc/scripts/*.sh")
   111    }
   112  }