A new package gets created in WHM through the Edit Package form. Three months later, the same package needs to exist on a second server, and the operator recreates it by memory — close, but not exactly the same. The two packages diverge over time as edits happen on each side. The fix is to treat packages as source code: a YAML or JSON file that describes the package, applied through whmapi1 addpkg (or editpkg for updates) to every server in the fleet.
What’s happening
whmapi1 addpkg accepts every field the WHM UI exposes — quota, bandwidth, feature list, max addons, max databases, theme, locale, CPU/memory/IO limits if CloudLinux is present. The call is deterministic: given the same inputs, you get the same package. The UI obscures this because it pre-fills fields with the logged-in reseller’s defaults, so two operators clicking through the form produce different packages from the same intent.
How to verify
List packages currently on the server and inspect one in detail:
whmapi1 list_packages
whmapi1 listpkgext pkg=gold-2026
ls /var/cpanel/packages/
cat /var/cpanel/packages/gold-2026
diff /var/cpanel/packages/gold-2026 /tmp/master/gold-2026
The on-disk package file is the canonical state. The listpkgext output is what cPanel will tell consumers. They should match; any divergence is local drift.
The fix
- Define the package as a source file — a YAML or JSON that lists every field and value. Keep it in your config-management repo, one file per package.
- Apply through
whmapi1 addpkgin your provisioning script:
whmapi1 addpkg \
name=gold-2026 \
quota=51200 \
bwlimit=1048576000 \
maxsubdomains=50 \
maxpop=unlimited \
featurelist=corporate \
cpmod=jupiter \
language=en \
cgi=1 \
shell=jailshell
- For updates, use
editpkginstead ofaddpkg. The shape is identical except for the verb; cPanel updates the existing package in place. - Run the same script against every server in the fleet. Drift detection becomes a diff between expected (the source file) and actual (
listpkgextoutput). - Mark packages as “managed by automation” — add a note field:
featurelist=corporate cpmod=jupiter notes="managed by config repo, hand edits will be overwritten". The notes field is read-only operationally but visible to operators in WHM. - For package retirements, the same flow runs
whmapi1 deletepkg name=silver-2022. Source-of-truth retirements deletion is in the source file; reapply across the fleet to converge.
Package-as-code is part of how Stack Harbor’s cPanel and WHM management practice keeps multi-server fleets converged on the same package definitions without manual reconciliation.