From cab934f909690ce57e222a2ed5d6a53c74679191 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 10 Nov 2011 13:51:55 -0500 Subject: add dovecot::config::file to be able to handle the different /etc/dovecot/conf.d files (similar to nginx/apache module) --- manifests/base.pp | 19 ++++++++++----- manifests/config/file.pp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 manifests/config/file.pp diff --git a/manifests/base.pp b/manifests/base.pp index e275a99..949935e 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,10 +1,5 @@ class dovecot::base { - - package { 'dovecot': - alias => 'dovecot', - ensure => installed, - } - + file { '/etc/dovecot.conf': source => [ "puppet:///modules/site-dovecot/config/${fqdn}/dovecot.conf", "puppet:///modules/site-dovecot/config/${dovecot::type}/dovecot.conf", @@ -15,6 +10,13 @@ class dovecot::base { notify => Service['dovecot'], owner => root, group => mail, mode => 0640; } + + file { 'config_dir': + path => '/etc/dovecot/conf.d', + ensure => directory, + require => Package['dovecot'], + owner => dovecot, group => 0, mode => 0755; + } file { '/var/log/dovecot': @@ -29,6 +31,11 @@ class dovecot::base { before => Service['dovecot'], owner => root, group => dovecot, mode => 0660; } + + package { 'dovecot': + alias => 'dovecot', + ensure => installed, + } include dovecot::logrotate diff --git a/manifests/config/file.pp b/manifests/config/file.pp new file mode 100644 index 0000000..78e6a28 --- /dev/null +++ b/manifests/config/file.pp @@ -0,0 +1,60 @@ +define dovecot::config::file ( + $ensure = present, + $source = 'absent', + $content = 'absent', + $destination = 'absent' +) + { + + # the default destination is 'absent', so if the user doesn't specify a + # destination, then we use the following defaults. If different systems + # implement different locations, we can trigger here off of operatingsystem + # and change the 'config_dir' path in base.pp to just be /etc/dovecot + $real_destination = $destination ? { + 'absent' => "${config_dir}/${name}", + default => $destination + } + + # the $name variable is set to dovecot_${name}, but the actual filename will + # be set to $name + file { "dovecot_${name}": + ensure => $ensure, + path => $real_destination, + notify => Service[dovecot], + owner => root, group => 0, mode => 0640; + } + + # the $content variable is 'absent' by default, so if the user doesn't + # specify anything for $content, then the following will be used, searching + # from the first source line until a file is found that matches. We use the + # standard search prioritizing the site-dovecot module first + case $content { + 'absent': { + $real_source = $source ? { + 'absent' => [ + "puppet:///modules/site-dovecot/config/${fqdn}/${name}", + "puppet:///modules/site-dovecot/config/${operatingsystem}/${lsbdistcodename}/${name}", + "puppet:///modules/site-dovecot/config/${operatingsystem}/${name}", + "puppet:///modules/site-dovecot/config/${name}", + "puppet:///modules/dovecot/config/${operatingsystem}/${lsbdistcodename}/${name}", + "puppet:///modules/dovecot/config/${operatingsystem}/${name}", + "puppet:///modules/dovecot/config/${name}" + ], + default => "puppet:///${source}", + } + File["dovecot_${name}"]{ + source => $real_source, + } + } + default: { + File["dovecot_${name}"]{ + content => $content, + } + } + } + File["dovecot_${name}"]{ + require => Package[dovecot], + } + } + + -- cgit v1.2.3