When provisioning automated cloud instances, orchestrating continuous integration (CI) runners, or deploying fleet workstations with Ansible or cloud-init in Ubuntu, installing packages via apt-get install can unexpectedly halt on interactive configuration dialogues. Packages like Postfix (mail server selection), Wireshark (non-superuser packet capture permissions), phpMyAdmin, or Kerberos pause the terminal, waiting for user input through the debconf terminal interface. To automate package installation completely non-interactively without prompting, Debian and Ubuntu provide the configuration pre-seeding utilities debconf-get-selections and debconf-set-selections.
Understanding How debconf Manages Package Questions
The Debian package configuration management system (debconf) separates package question prompts from backend configuration scripts:
- Debconf Database: Stores configuration keys, data types (string, boolean, select, password), and chosen answers in
/var/cache/debconf/config.datandpasswords.dat. - Preseeding: Loading answers into the debconf database before
apt-getruns. Whendpkgunpacks the package, debconf finds existing answers in its cache and skips interactive prompts entirely. - DEBIAN_FRONTEND=noninteractive: Tells APT to suppress all terminal prompts; when combined with preseeded answers, installations proceed fully unattended.
Installing the debconf-utils Package
The commands required to extract and inject configuration answers reside inside the debconf-utils package:
sudo apt-get update
sudo apt-get install -y debconf-utils
This provides debconf-get-selections and debconf-set-selections.
Extracting Existing Answers from a Configured System
The most reliable way to find the exact debconf question strings for a package is to install and configure it manually once on a reference machine, then export its registered answers:
debconf-get-selections | grep wireshark-common
The command emits tab-separated preseed entries:
wireshark-common wireshark-common/install-setuid boolean true
Each preseed line consists of four columns:
- Package Name: (e.g.,
wireshark-common) - Question Template: (e.g.,
wireshark-common/install-setuid) - Variable Type: (
boolean,string,select,password,multiselect) - Preseeded Value: (e.g.,
true)
Preseeding Answers Before Package Installation
To inject answers into the debconf database on a target machine before running the package manager, pipe preseed strings directly into debconf-set-selections:
For example, to configure Wireshark to allow non-root users to capture network packets without an interactive prompt:
echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
For complex multi-question packages like Postfix:
sudo debconf-set-selections << 'EOF'
postfix postfix/main_mailer_type select Internet Site
postfix postfix/mailname string mail.example.com
EOF
To verify that the answers are loaded into debconf\u2019s database:
sudo debconf-show postfix
Active preseeded values appear with an asterisk (*) beside them.
Executing Fully Non-Interactive APT Installations
With answers preseeded, execute the package installation using the DEBIAN_FRONTEND=noninteractive environment variable:
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postfix wireshark-common
APT downloads, unpacks, and configures the services immediately without pausing for user keystrokes, rendering deployment scripts 100% reliable.
Automating via Preseed Files in Scripts and Cloud-Init
For automated server provisioning, save all required preseed answers into a flat text file (e.g., /tmp/preseed.cfg):
# Enterprise debconf preseed definitions
iptables-persistent iptables-persistent/autosave_v4 boolean true
iptables-persistent iptables-persistent/autosave_v6 boolean true
wireshark-common wireshark-common/install-setuid boolean true
Then load the file in your provisioning script before running package installations:
sudo debconf-set-selections /tmp/preseed.cfg
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y iptables-persistent wireshark
This clean separation between configuration data and package orchestration ensures seamless unattended deployments across all Debian and Ubuntu systems.