Passing default answers to apt-get package install questions?

Tarka asked:

I’m trying to write a configuration script for new servers, and one of the first steps is to install a series of required packages, such as MySQL, phpMyAdmin, etc. using apt-get install However, when dpkg tries to configure them it asks you for a few options, such as MySQL root password, phpMyAdmin passwords, what server to use, etc.

Since I will likely be passing this script on to co-workers who are unlikely to read the prompts, and my desire to simply start it and walk away, I’d like to know how to pass in a series of “default” answers/values for it to use. This might include usernames/passwords/other dynamic values passed on command line.

I realize that having passwords in a script is a security issue, but I’m willing to ignore it, particularly in the more general sense of installing packages that an answer to this would imply.

My answer:

export DEBIAN_FRONTEND=noninteractive
apt-get -q -y install _packages_

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.