ubuntults
is a set of configuration files used to build automated Ubuntu LTS virtual machine images using Packer.
This Packer configuration file allows you to OVA images usable for VMware and VirtualBox on a vSphere ESX host.
- Packer to run the build process
- VMware vCenter and VMware ESXI to build on
tar
for building an OVA from the export OVF files
- Unattended installation of Ubuntu LTS server from downloaded ISO
- Some cleanup via
post_install.sh
script - Export VM and package as OVA file
- Install Packer
- Allow the Packer vSphere plugin through the firewall, as it will serve the preseed file via HTTP on a random port
The variables required for the build are defined in the variables.pkr.hcl
file.
The definition contains also default values to build the latest LTS release.
You can and must overwrite these variables in the file, in a variable file or via commandline.
See the Packer documentation on user variables for details.
To create a VM image using a vCenter connection when you set your environment:
# Set all the required packer variables for the vSphere connection, e.g. for Windows:
$env:PKR_VAR_vcenter_server="vcenter.domain.name"
$env:PKR_VAR_vcenter_user="build"
$env:PKR_VAR_vcenter_password="Passw0rd."
$env:PKR_VAR_vcenter_datacenter="Build"
$env:PKR_VAR_esx_host="esx.domain.name"
# IP Adress of the interface with default route
$env:PKR_VAR_http_ip=(Get-NetIPAddress -AddressFamily IPv4 -ifIndex (Get-NetRoute -DestinationPrefix 0.0.0.0/0).ifIndex).IPAddress
cd <path-to-git-root-directory>
# Define var file as required. If not set the latest LTS release will be build
packer build -var-file="ubuntults2204.pkrvars.hcl" .
Wait for the build to finish to find the generated OVA file in the build/
folder.
The default credentials for this VM image are:
Username | Password |
---|---|
ubuntu |
Passw0rd. |
root |
Passw0rd. |
- Packer build config for Ubuntu server: subiquity vs debian-installer
- Ubuntu Autoinstall Reference
- CloudInit Documentation
The Gitlab-CI build copies the resulting OVA to a SMB share for further usage. The following variables have to be set in the Gitlab UI
Variable | Description |
---|---|
LTS_VERSION |
LTS version to build in form like '2204' for Ubuntu LTS 22.04 |
SMB_PATH |
The UNC path to the SMB share where to put the resulting OVA file - the user running Gitlab-Runner must have write access |