How do you avoid apt/dnf prompts in automation?
BeginnerProductionPatching, Automation & Golden Images
Answer
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
sudo dnf -y upgrade
Use apt-get rather than apt in scripts; apt warns that its CLI is not stable for scripting. --force-confold keeps your modified config files when packages ship new ones.
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