29

I'm trying to build an Ansible Playbook to deploy some Ubuntu 12.04 servers on Linode, but my problem seems to be an Ubuntu one. When I run different combinations of apt-get or aptitude I always get the following dialog that I have to respond to.

Package configuration dialog

I'd like this to be answered from the command line so that it doesn't interrupt the automatic deployment. Any ideas?

My current commands are below. Note that I'm trying to set DEBIAN_FRONTEND:

#!/bin/bash

echo 'DEBIAN_FRONTEND="noninteractive"' >> /etc/profile
echo 'DEBIAN_FRONTEND="noninteractive"' >> ~/.profile

source /etc/profile
source ~/.profile

# This next line is the one that pops up the dialog
sudo aptitude -y install iptables-persistent

# Need this to fix an issue with the package post-install (this works fine.)
sudo sed \
    -i 's/\(modprobe -q ip6\?table_filter\)/\1 || true/g' \
    /var/lib/dpkg/info/iptables-persistent.postinst; \
sudo aptitude install iptables-persistent

5 Answers 5

37

Try using debconf-set-selections to set the value before installing the package:

echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections

Or, via ansible

- name: prevent the iptables-peristent install dialog
  debconf: name=iptables-persistent question={{ item }} vtype=boolean value=true
  with_items:
  - iptables-persistent/autosave_v4
  - iptables-persistent/autosave_v6
- name: install iptables-persistent
  apt: name=iptables-persistent
3
  • @Braiam I added sudo Sep 3, 2013 at 13:54
  • You might want to add iptables-persistent iptables-persistent/autosave_v4 boolean true too.
    – Braiam
    Sep 3, 2013 at 14:14
  • @Braiam Added v4 Sep 3, 2013 at 14:29
0

You missed -q. Try:

sudo DEBIAN_FRONTEND=noninteractive aptitude install -y -q iptables-persistent
3
  • 1
    That didn't work on 12.04 :( I already have to do the other fixup, so I wonder if the package just ignores the environment variable. Aug 31, 2013 at 19:39
  • 1
    I tested this in a 12.04-desktop vm before posting. So maybe it's related to your 12.04-server?
    – Germar
    Aug 31, 2013 at 20:08
  • Debian shows the same message...
    – Braiam
    Sep 2, 2013 at 22:39
0

I think you should consider doing a debconf database to automatize all the process. This is a nonintuitive process and requires lot of work, like repackaging your own deb files, to make it work and is called "debconf preseeding".

There are several examples in the Debian wiki about how to do this:

Depending of the time and circumstances you will select one (that why I didn't go into details). Take one that seems useful, and stick with it until the end.

If you run into problems ask another question detailing what you are trying to do, and how you plan to do it.

0

Minor fix/adjustment to @lorin-hochstein's Ansible-based answer to non-interactively install iptables-persistent in which the task requires the sudo-privilges to run successfully (added the become: yes line): ## Prevent iptables-persistent pckgs install dialog (debconf-set-selections) - name: prevent the iptables-peristent install dialog become: yes debconf: name=iptables-persistent question={{ item }} vtype=boolean value=true with_items: - iptables-persistent/autosave_v4 - iptables-persistent/autosave_v6 - name: install iptables-persistent apt: name=iptables-persistent

0

If building a Docker image:

RUN echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections \
  && echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections
RUN apt-get install -y iptables-persistent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.