How to configure exim4 with a smarthost via puppet

configuration-managementdpkgeximpuppet

I have tried to automate the exim setup via puppet. I followed the approach described here, whiched worked for me for a few packages, but for exim I had a problem: one selection was not correctly applied on a fresh system.

When setting up exim or running dpkg-reconfigure exim4-config, I select the smarthost option as shown in the screenshot below
enter image description here

Exporting the selections to a file results in the following (stripped some parts)

$ debconf-get-selections | grep exim
exim4-config    exim4/dc_other_hostnames        string  my.other.hostname
exim4-config    exim4/dc_eximconfig_configtype  select  mail sent by smarthost; received via SMTP or fetchmail
exim4-config    exim4/no_config boolean true
exim4-config    exim4/hide_mailname     boolean true
exim4-config    exim4/dc_postmaster     string
exim4-config    exim4/dc_smarthost      string  my.smarthost.com::port
exim4-config    exim4/dc_relay_domains  string
exim4-config    exim4/dc_relay_nets     string
exim4-base      exim4/purge_spool       boolean false
exim4-config    exim4/mailname  string  my.mail.name

As you can see, all options look just fine. Note that dc_eximconfig_configtype (line 2 of the output) shows the text of the selected value from the interactive configuration.

When trying to use this export in my puppet configuration, that one parameter is not correctly applied:

package { "exim4":
  responsefile => my-exported-exim4-debconf,
  ensure => installed;
}

I have also tried to import the configuration via debconf-get-selections, which I assume puppet is doing in this case on a debian environment, but it seems to be ignored without providing any indication.

Is this a known error? Do you know how I can either solve this problem with a different configuration export (e.g. provide an integer index for that parameter), or suggest an alternative of distributing the exim configuration with puppet?

Thank you
Kariem

Best Answer

Since the exim install doesn't come up with the config options, and just defaults to local mode, that may be why the options are getting set.

Anyway, one good option would be instead of using a dpkg-reconfigure, have puppet config the file /etc/exim4/update-exim4.conf.conf then run the command update-exim4.conf.

After you run the dpkg config once, the file will have the options set for you to reference for puppet's master copy, you'll probably want to use a template in puppet since there's hostnames in the file as well.