How do you handle "Could not get lock /var/lib/dpkg/lock-frontend" in automation?
IntermediateProductionPatching, Automation & Golden Images
Answer
Another apt process holds the lock, often unattended-upgrades or cloud-init on a fresh instance. Do not delete lock files. Wait for it:
cloud-init status --wait
while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 5; done
apt-get also supports -o DPkg::Lock::Timeout=300. In images, disable automatic upgrades on first boot if your pipeline handles patching.
More on Patching, Automation & Golden Images
What does a good Linux patching strategy look like?BeginnerIn-place patching vs immutable image replacement: which do you prefer?IntermediateHow do you know whether a server needs a reboot after patching?BeginnerHow do you configure automatic security updates?BeginnerWhat is kernel live patching?IntermediateHow do you roll kernel updates across a 200-node fleet safely?Advanced