Package install during preseed default finish fails

Problem:

Automated installation of katello-host-tools fails.

Expected outcome:

Successful installation of packages listed in template “preseed default finish”.

Foreman and Proxy versions:
Foreman & Proxy 3.15.0

Foreman and Proxy plugin versions:
As above

Distribution and version:
Foreman: CentOS Stream 9
Deployed host: Ubuntu 22.04

Other relevant data:
Relevant logs on the host:

Aug 05 11:48:55 test-host.domain.com subiquity_log.1957[49005]: Reading package lists...
Aug 05 11:48:55 test-host.domain.com subiquity_log.1957[49005]: Building dependency tree...
Aug 05 11:48:55 test-host.domain.com subiquity_log.1957[49005]: Reading state information...
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: The following additional packages will be installed:
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]:   katello-upload-profile python3-katello-host-tools
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]:   python3-katello-host-tools-tracer
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: The following NEW packages will be installed:
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]:   katello-host-tools-tracer katello-upload-profile python3-katello-host-tools
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]:   python3-katello-host-tools-tracer
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: 0 upgraded, 4 newly installed, 0 to remove and 48 not upgraded.
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: Need to get 5234 B/18.3 kB of archives.
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: After this operation, 93.2 kB of additional disk space will be used.
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: Get:1 https://oss.atix.de/Ubuntu22LTS stable/main amd64 python3-katello-host-tools-tracer all 4.4.0-4 [3304 B]
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: Get:2 https://oss.atix.de/Ubuntu22LTS stable/main amd64 katello-host-tools-tracer all 1.0-1 [1930 B]
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: unable to initialize frontend: Dialog
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: (TERM is not set, so the dialog frontend is not usable.)
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: falling back to frontend: Readline
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: unable to initialize frontend: Readline
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: (This frontend requires a controlling tty.)
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: debconf: falling back to frontend: Teletype
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49011]: dpkg-preconfigure: unable to re-open stdin:
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: Fetched 5234 B in 0s (37.2 kB/s)
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: dpkg: error: need an action option
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Type dpkg --help for help about installing and deinstalling packages [*];
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Use 'apt' or 'aptitude' for user-friendly package management;
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Type dpkg -Dhelp for a list of dpkg debug flag values;
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Type dpkg --force-help for a list of forcing options;
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Type dpkg-deb --help for help about manipulating *.deb files;
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49027]: Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
Aug 05 11:48:56 test-host.domain.com subiquity_log.1957[49005]: E: Sub-process /usr/bin/dpkg returned an error code (2)

Modifying template “debian_register” to include export DEBIAN_FRONTEND=noninteractive got rid of the debconf errors. but the apt-get package installation still fails.

This snippet from template “pkg_manager” defines the installer for Debian derivatives:

  [...]
elif [ -f /etc/debian_version ]; then
  PKG_MANAGER='apt-get'
  PKG_MANAGER_INSTALL="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install -y"
  PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
  PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [...]

So I see no reason for the error thrown: dpkg: error: need an action option. If I replace the section in template “debian_register” as follows then package deployment does work. What gives?!

  [...]

  <% if debian_install_host_tools -%>
    export DEBIAN_FRONTEND=noninteractive
    #$PKG_MANAGER_INSTALL katello-host-tools
    apt install -y katello-host-tools
  <% end -%>

  <% if debian_install_host_tracer_tools -%>
    #$PKG_MANAGER_INSTALL katello-host-tools-tracer
    apt install -y katello-host-tools-tracer
  <% end -%>
<% end -%>