-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Ubuntu 20.04 base image template into HCL2
This runs the `packer hcl2_upgrade` command on the template file of the Ubuntu 20.04 base image to use the new HCL2 format instead of the legacy JSON one.
- Loading branch information
1 parent
9079a5d
commit e10539d
Showing
3 changed files
with
184 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json
This file was deleted.
Oops, something went wrong.
182 changes: 182 additions & 0 deletions
182
packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json.pkr.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
packer { | ||
required_plugins { | ||
virtualbox = { | ||
source = "github.com/hashicorp/virtualbox" | ||
version = "~> 1" | ||
} | ||
} | ||
} | ||
|
||
variable "box_basename" { | ||
type = string | ||
default = "ubuntu-20.04" | ||
} | ||
|
||
variable "cpus" { | ||
type = string | ||
default = "2" | ||
} | ||
|
||
variable "disk_size" { | ||
type = string | ||
default = "20960" | ||
} | ||
|
||
variable "git_revision" { | ||
type = string | ||
default = "__unknown_git_revision__" | ||
} | ||
|
||
variable "headless" { | ||
type = string | ||
default = "true" | ||
} | ||
|
||
variable "http_proxy" { | ||
type = string | ||
default = "${env("http_proxy")}" | ||
} | ||
|
||
variable "https_proxy" { | ||
type = string | ||
default = "${env("https_proxy")}" | ||
} | ||
|
||
variable "iso_checksum" { | ||
type = string | ||
default = "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2" | ||
} | ||
|
||
variable "iso_name" { | ||
type = string | ||
default = "ubuntu-20.04.1-legacy-server-amd64.iso" | ||
} | ||
|
||
variable "memory" { | ||
type = string | ||
default = "4096" | ||
} | ||
|
||
variable "metadata" { | ||
type = string | ||
default = "floppy/dummy_metadata.json" | ||
} | ||
|
||
variable "mirror" { | ||
type = string | ||
default = "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases" | ||
} | ||
|
||
variable "mirror_directory" { | ||
type = string | ||
default = "20.04.1/release/" | ||
} | ||
|
||
variable "name" { | ||
type = string | ||
default = "ubuntu-20.04" | ||
} | ||
|
||
variable "no_proxy" { | ||
type = string | ||
default = "${env("no_proxy")}" | ||
} | ||
|
||
variable "preseed_path" { | ||
type = string | ||
default = "../../http/ubuntu-20.04/preseed.cfg" | ||
} | ||
|
||
variable "template" { | ||
type = string | ||
default = "vagrant-base-ubuntu-20.04-amd64" | ||
} | ||
|
||
variable "version" { | ||
type = string | ||
default = "2.1.TIMESTAMP" | ||
} | ||
|
||
locals { | ||
build_timestamp = "${timestamp()}" | ||
} | ||
|
||
source "virtualbox-iso" "ubuntu" { | ||
boot_command = [ | ||
"<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>", | ||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>", | ||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>", | ||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>", | ||
"/install/vmlinuz<wait>", | ||
" auto<wait>", | ||
" console-setup/ask_detect=false<wait>", | ||
" console-setup/layoutcode=us<wait>", | ||
" console-setup/modelcode=pc105<wait>", | ||
" debconf/frontend=noninteractive<wait>", | ||
" debian-installer=en_US.UTF-8<wait>", | ||
" fb=false<wait>", | ||
" initrd=/install/initrd.gz<wait>", | ||
" kbd-chooser/method=us<wait>", | ||
" keyboard-configuration/layout=USA<wait>", | ||
" keyboard-configuration/variant=USA<wait>", | ||
" locale=en_US.UTF-8<wait>", | ||
" netcfg/get_domain=vm<wait>", | ||
" netcfg/get_hostname=vagrant<wait>", | ||
" grub-installer/bootdev=/dev/sda<wait>", | ||
" noapic<wait>", | ||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>", | ||
" -- <wait>", | ||
"<enter><wait>" | ||
] | ||
boot_wait = "10s" | ||
disk_size = "${var.disk_size}" | ||
guest_os_type = "Ubuntu_64" | ||
hard_drive_interface = "sata" | ||
headless = "${var.headless}" | ||
http_directory = "../../http/ubuntu-20.04" | ||
iso_checksum = "${var.iso_checksum}" | ||
iso_urls = [ | ||
"iso/ubuntu-20.04.1-legacy-server-amd64.iso", | ||
"http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04.1-legacy-server-amd64.iso" | ||
] | ||
output_directory = "../../builds/virtualbox/vagrant-base-ubuntu-20.04-amd64" | ||
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now" | ||
ssh_password = "vagrant" | ||
ssh_port = 22 | ||
ssh_username = "vagrant" | ||
ssh_wait_timeout = "10000s" | ||
vboxmanage = [ | ||
["modifyvm", "{{ .Name }}", "--memory", "${var.memory}"], | ||
["modifyvm", "{{ .Name }}", "--cpus", "${var.cpus}"] | ||
] | ||
virtualbox_version_file = ".vbox_version" | ||
vm_name = "${var.template}" | ||
} | ||
|
||
build { | ||
sources = [ | ||
"source.virtualbox-iso.ubuntu" | ||
] | ||
|
||
provisioner "shell" { | ||
environment_vars = [ | ||
"HOME_DIR=/home/vagrant", | ||
"http_proxy=${var.http_proxy}", | ||
"https_proxy=${var.https_proxy}", | ||
"no_proxy=${var.no_proxy}" | ||
] | ||
execute_command = "echo 'vagrant' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'" | ||
expect_disconnect = true | ||
scripts = [ | ||
"../../scripts/ubuntu/update.sh", | ||
"../../scripts/common/sshd.sh", | ||
"../../scripts/ubuntu/networking.sh", | ||
"../../scripts/ubuntu/sudoers.sh", | ||
"../../scripts/ubuntu/vagrant.sh", | ||
"../../scripts/common/virtualbox.sh", | ||
"../../scripts/ubuntu/cleanup.sh", | ||
"../../scripts/common/minimize.sh" | ||
] | ||
} | ||
|
||
} |