🏗️ Build a minimal Ubuntu image for VMware vCenter or ESXi in minutes
Official template builder for WUcenter Ansible framework.
- Dual VMware products support
- Supports vCenter cluster API (
vsphere-iso
) - Supports single ESXi host (
vmware-iso
)
- Supports vCenter cluster API (
- Ubuntu products support
- Supports Bionic Server (18.04.04)
- Supports Focal Server (20.04)
- Minimal & Up-To-Date
- ~220 packages, ~850MB
- Static IP assignment
- Oldschool NIC names, no IPv6
- HWE Virtual Kernel
- Provisioning-ready
- Python 3.6, compat Ansible >=2.5
- OpenSSH server, PasswordAuthentication=yes, UseDNS=no
ansibler
user/pass, uid 999, password-less sudoer
- Since Packer 1.5.2, vSphere builder (
vsphere-iso
) is natively supported - Previously, Packer 1.3.5 was compatible with vSphere Builder by JetBrains
VMware ESXi is natively supported by Packer vmware-iso
builder.
As seen here some tweaking is required on the ESXi server.
# Enable GuestIPHack for Hashicorp Packer
esxcli system settings advanced set -o /Net/GuestIPHack -i 1
# Un-firewall VNC ports for Hashicorp Packer
chmod 644 /etc/vmware/firewall/service.xml
sed -i '/<\/ConfigRoot>/d' /etc/vmware/firewall/service.xml
cat <<'EOF' >>/etc/vmware/firewall/service.xml
<!-- Hashicorp Packer enablement: open 5900-6000 TCP ports (VNC) -->
<service id="1000">
<id>packer-vnc-custom</id>
<rule id="0000">
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>
<begin>5900</begin>
<end>6000</end>
</port>
</rule>
<enabled>true</enabled>
<required>true</required>
</service>
</ConfigRoot>
EOF
chmod 444 /etc/vmware/firewall/service.xml
esxcli network firewall refresh
- Clone the project somewhere
- Copy latest Packer binary in project or
$PATH
Create a configuration file from samples/*.json
:
- Setup static network configuration:
NET_*
. - Setup VMware server credentials:
VMW_*
Remeber, 3 configuration levels are available:
- Default variables in
ubuntu-{bionic,focal}.{exsi,vcenter}.json
- Custom variables in
samples/{exsi,vcenter}.json
- Runtime arguments as
-var 'VMW_USERNAME=user@vc.lan' -var 'VMW_PASSWORD=<secret>'
Recommended usage is using var-file
s for config, except maybe for secrets and of course shell variables:
- This command will build a bionic VM on vCenter server:
time PACKER_LOG=1 packer build -on-error=ask -force \
-var-file=samples/vcenter.json \
-var 'NAME=MY_TEMPLATE_' \
-var 'VERSION=1.1' \
ubuntu-bionic.vcenter.json
- This command will build a bionic VM on ESXi server:
time PACKER_LOG=1 packer build -on-error=ask -force \
-var-file=samples/esxi.json \
-var 'NAME=MY_TEMPLATE_NAME_' \
-var 'VERSION=1.1' \
ubuntu-bionic.esxi.json
- This command will create a focal VM template on vCenter cluster:
time PACKER_LOG=1 packer build -on-error=ask -force \
-var-file=samples/vcenter.json \
-var 'VERSION=2.1' \
ubuntu-focal.vcenter.json
The following self-explaining template variables are used:
- NAME
- VERSION
- RSC_CPU
- RSC_RAM
- RSC_DISK
- NET_GW
- NET_IP
- NET_NM
- NET_NS
- VMW_VCENTER
- VMW_USERNAME
- VMW_PASSWORD
- VMW_CLUSTER
- VMW_DATASTORE
- VMW_NETWORK
- VMW_FOLDER
- SSH_USERNAME
- SSH_PASSWORD
Note that modifying SSH_USERNAME & SSH_PASSWORD also requires editing passwd/*
values in corresponding d-i/SEED_*.CFG
file.
d-i
is preseeded with a virtual floppy.
d-i
is extended by a custom script triggered by preseed/late_command
.
Networking is configured from Linux kernel boot command.
You can simply customize your template by editing debian-installer seed and corresponding "late" script in d-i/
- Packer vCenter builder https://github.com/jetbrains-infra/packer-builder-vsphere#parameter-reference
- Packer ESXi builder https://packer.io/docs/builders/vmware-iso.html#vmware-iso-builder-configuration-reference
- Ubuntu preseeding https://help.ubuntu.com/lts/installation-guide/s390x/apbs04.html
- Workaround more VMware bugs on bionic