package { 'mailman':
ensure => installed,
require => Package['exim4'],
}
maillist { 'mailman':
ensure => 'present',
admin => $admin,
description => 'Site list',
password => $master_password,
require => Package['mailman'],
}
If package "mailman" has not been installed, then puppet complains that it "Could not find a default provider for maillist". It seems it considers this to be an error in the manifest, because it aborts entirely and does not apply any configuration. As a result, it does not process the "package { 'mailman': ... }" directive, which means it does not install mailman. I need to comment out the maillist directive, then apply the configuration so that mailman is installed, then uncomment and reapply. But this is not satisfactory.
How can I do it in a better way?
There was a fix in Puppet 2.7.8, for issue #6907 that enables a provider to be installed or synchronised during the run that it's being used in (subject to normal dependencies being specified). See the 2.7.8 release notes too.
You should find it fixes this case, allowing you to install the Mailman dependency for the maillist provider during the same run.
One simple thing you could do is create a custom fact that will report if mailman is installed on your system. Just have the fact return true or false depending on the presence of the binary.
Then just add a conditional to your your manifest.