What exactly happens in the "graphic setup" of postfix?

Solution 1:

That setup is part of the Debian package for Postfix.

Take a look at the ansible.builtin.debconf Module, using that you can have Ansible run apt with the right configuration options (the same as you would enter with that dialog).

For example:

- name: Select Postfix config
  ansible.builtin.debconf:
    name: postfix
    question: postfix/main_mailer_type
    value: Internet Site
    vtype: select

If you really want to dig into it then you can find the sources for the config scripts, most importantly the postfix.config and templates; but that should not be necessary.