Other than Debian, preseed can be used with any Debian based distribution out there, like Ubuntu, Mint, Elementary OS etc.
Preseed concept saves time! And time saving is something what every good system administrator values most. With that in mind, I will try to make this guide as short as possible. As stated above, lets imagine we have a few machines where we need to install same software packages. To generate a preseed file, we will use our first machine, and for that we will need a debconf-utils package. Once file is generated, we will use it as an answer input on all other machines.
Preseed – generating an answer file
man-db package is present in almost any installation where Debian or Debian based distro is used, thus making it a good example for this guide.
As an example to demonstrate a pressed concept, man-db package will be used. Also, as stated above, you will need a debconf-utils package. Debconf itself needs to be configured to show us all the questions we might be asked during the installation of a packages, so we will need to reconfigure it to show us that questions. Let’s start by doing that. Execute the following in your terminal:
echo -e "debconf debconf/frontend select Dialog\ndebconf debconf/priority select low" | debconf-set-selections
Let’s install debconf-utils package now. Be aware, if this is a fresh installation, you will need to enable universe repository (at least on Ubuntus). Edit your sources.list file to do so. To install the package, execute the following:
apt-get update apt-get install --no-install-recommends debconf-utils
All the tools we need to create our answer file are in place, so let’s install the example man-db package. Execute the following:
apt-get install -y --no-install-recommends man-db
Since we didn’t provide any preseed options before package installation, debconf “greets” us with a dialog that requires user input. Select No and press Enter to continue.
Now we can create an answer file which will automate man-db installation on other machines where it needs to be installed. To do so, we will use debconf-get-selections tool installed with debconf-utils package. So execute the following:
debconf-get-selections |grep man-db
The result will be the following:
man-db man-db/install-setuid boolean false man-db man-db/auto-update boolean true
As you can see the first option which defines should mandb be installed ‘setuid’ corresponds to answer (false == No) we offered to when debconf asked us the same question during package installation. To actually create an answer file for other machines, you need to save the output of the debconf-get-selections. So create man-db.preseed file and paste the result from above in it.
Preseed – putting answer file to work
Now that you have your answer file, you can distribute it to all machines where a man-db package needs to be installed. Before you can actually install the package, you need to tell debconf not to ask you any questions during the installation. You can achieve this in one of three ways (the ones I know of). You can reconfigure debconf package:
When asked, select “Noninteractive” and “critical” options to disable debconf from answering questions. You can do the same by executing the following:
echo -e "debconf debconf/frontend select Noninteractive\ndebconf debconf/priority select critical" | debconf-set-selections
Third option you have is one I like most. There is one nice system variable called “DEBIAN_FRONTEND” which if it’s value is set to noninteractive, will disable debconf from asking any questions. So you can temporarily disable debconf from asking question (only for current session), and have it in full Dialog mode (ask all questions) for all new installations and packages you don’t have a preseed file for.
To put our preseed answer file in action and install man-db package, execute the following:
cat man-db.preseed | debconf-set-selections DEBIAN_FRINTEND=noninteractive apt-get install --no-install-recommends -y man-db
And there you have it, man-db package is installed with options taken from man-db.preseed file and no questions were asked from debconf.
Very important to remember here is, if you set debconf in noninteractive mode and you don’t provide a preseed file, packages will be installed with default options. This can lead to some unexpected and unwanted behavior of installed software, so be careful how you use it.
You can find out more about automating and preseeding Debian based distributions here. Thanks for reading.