APT and packages with interactive configuraton?

Hello,

I am trying to set up Postfix on a Debian 12 web server according to this guide. About halfway through the article the author installs Postfix via sudo apt-get install postfix -y, which opens an interactive configuration wizard before the package is installed.

I have not been able to find anything the the documentation of ansible.builtin.apt for answering these interactive questions. Is there a way, or am I out of luck?

@HiPhish
Hi, try this:

- ansible.builtin.apt:
    name: postfix
    state: present
  environment:
    DEBIAN_FRONTEND: noninteractive

The noninteractive means:

This is the anti-frontend. It never interacts with you at all, and makes the default answers be used for all questions. It might mail error messages to root, but that’s it; otherwise it is completely silent and unobtrusive, a perfect frontend for automatic installs. If you are using this front-end, and require non-default answers to questions, you will need to preseed the debconf database; see the section below on Unattended Package Installation for more details.
https://manpages.debian.org/jessie/debconf-doc/debconf.7.en.html#Frontends

You can get and set the answers before installing postfix using the ansible.builtin.debconf module, for example to get all the questions and what has been set (a * indicates a modified answer) after postfix has been installed:

debconf-show postfix

Thanks, debconf is the mechanism was looking for. It was impossible to find anything useful online searching for “wizard” or “configuration”, but searching for debconf gave me the results I needed.