diff --git a/.github/workflows/vagrant-box-archivematica.yml b/.github/workflows/vagrant-box-archivematica.yml index 37030210..fefbecb7 100644 --- a/.github/workflows/vagrant-box-archivematica.yml +++ b/.github/workflows/vagrant-box-archivematica.yml @@ -24,15 +24,11 @@ jobs: run: | echo "USER=$USER" >> $GITHUB_ENV echo "LOGNAME=$USER" >> $GITHUB_ENV - - name: Install packer plugins - run: | - packer plugins install github.com/hashicorp/virtualbox - packer plugins install github.com/hashicorp/ansible - packer plugins install github.com/hashicorp/vagrant - name: Build run: | cd ${{ github.workspace }}/packer/templates/vagrant-base-ubuntu-20.04-amd64 - packer build -on-error=abort template.json + packer init template.json.pkr.hcl + packer build -on-error=abort template.json.pkr.hcl - name: Upload base image uses: actions/upload-artifact@v4 with: diff --git a/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json b/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json deleted file mode 100644 index faee6afc..00000000 --- a/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "builders": [ - { - "boot_command": [ - "", - "", - "", - "", - "/install/vmlinuz", - " auto", - " console-setup/ask_detect=false", - " console-setup/layoutcode=us", - " console-setup/modelcode=pc105", - " debconf/frontend=noninteractive", - " debian-installer=en_US.UTF-8", - " fb=false", - " initrd=/install/initrd.gz", - " kbd-chooser/method=us", - " keyboard-configuration/layout=USA", - " keyboard-configuration/variant=USA", - " locale=en_US.UTF-8", - " netcfg/get_domain=vm", - " netcfg/get_hostname=vagrant", - " grub-installer/bootdev=/dev/sda", - " noapic", - " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", - " -- ", - "" - ], - "boot_wait": "10s", - "disk_size": "{{user `disk_size`}}", - "guest_os_type": "Ubuntu_64", - "hard_drive_interface": "sata", - "headless": "{{ user `headless` }}", - "http_directory": "../../http/ubuntu-20.04", - "iso_checksum": "{{user `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", - "type": "virtualbox-iso", - "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "{{ user `memory` }}" - ], - [ - "modifyvm", - "{{.Name}}", - "--cpus", - "{{ user `cpus` }}" - ] - ], - "virtualbox_version_file": ".vbox_version", - "vm_name": "{{ user `template` }}" - } - ], - "provisioners": [ - { - "environment_vars": [ - "HOME_DIR=/home/vagrant", - "http_proxy={{user `http_proxy`}}", - "https_proxy={{user `https_proxy`}}", - "no_proxy={{user `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" - ], - "type": "shell" - } - ], - "variables": { - "box_basename": "ubuntu-20.04", - "build_timestamp": "{{isotime}}", - "cpus": "2", - "disk_size": "20960", - "git_revision": "__unknown_git_revision__", - "headless": "true", - "http_proxy": "{{env `http_proxy`}}", - "https_proxy": "{{env `https_proxy`}}", - "iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2", - "iso_name": "ubuntu-20.04.1-legacy-server-amd64.iso", - "memory": "4096", - "metadata": "floppy/dummy_metadata.json", - "mirror": "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases", - "mirror_directory": "20.04.1/release/", - "name": "ubuntu-20.04", - "no_proxy": "{{env `no_proxy`}}", - "preseed_path": "../../http/ubuntu-20.04/preseed.cfg", - "template": "vagrant-base-ubuntu-20.04-amd64", - "version": "2.1.TIMESTAMP" - } -} diff --git a/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json.pkr.hcl b/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json.pkr.hcl new file mode 100644 index 00000000..3cc7f68d --- /dev/null +++ b/packer/templates/vagrant-base-ubuntu-20.04-amd64/template.json.pkr.hcl @@ -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 = [ + "", + "", + "", + "", + "/install/vmlinuz", + " auto", + " console-setup/ask_detect=false", + " console-setup/layoutcode=us", + " console-setup/modelcode=pc105", + " debconf/frontend=noninteractive", + " debian-installer=en_US.UTF-8", + " fb=false", + " initrd=/install/initrd.gz", + " kbd-chooser/method=us", + " keyboard-configuration/layout=USA", + " keyboard-configuration/variant=USA", + " locale=en_US.UTF-8", + " netcfg/get_domain=vm", + " netcfg/get_hostname=vagrant", + " grub-installer/bootdev=/dev/sda", + " noapic", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", + " -- ", + "" + ] + 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" + ] + } + +}