summaryrefslogtreecommitdiff
path: root/manifests/config/file.pp
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2014-02-25 15:43:42 +0100
committervarac <varacanero@zeromail.org>2014-02-25 15:43:42 +0100
commitc2539d1ea132e137d29f3183e7aac568462865b0 (patch)
treeaa71997081abe88e95fd07d8e532ce8afbcf7cea /manifests/config/file.pp
parent705fd0a13dc4d2f073819947159e28b54c286550 (diff)
parent34333c48ba5662228c37a70eb099ec9a5f96b5ac (diff)
Merge branch 'leap_master'
Conflicts: files/munin/dovecot manifests/base.pp manifests/centos.pp manifests/debian.pp manifests/expire.pp manifests/init.pp manifests/munin.pp manifests/quota.pp manifests/sieve.pp manifests/sql.pp
Diffstat (limited to 'manifests/config/file.pp')
-rw-r--r--manifests/config/file.pp76
1 files changed, 76 insertions, 0 deletions
diff --git a/manifests/config/file.pp b/manifests/config/file.pp
new file mode 100644
index 0000000..e6e93c3
--- /dev/null
+++ b/manifests/config/file.pp
@@ -0,0 +1,76 @@
+define dovecot::config::file (
+ $ensure = present,
+ $source = 'absent',
+ $content = 'absent',
+ $destination = 'absent',
+ $mode = 'absent',
+ $owner = 'absent',
+ $group = '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 'dovecot_config_dir' path in base.pp to just be /etc/dovecot
+ $real_destination = $destination ? {
+ 'absent' => "/etc/dovecot/conf.d/${name}",
+ default => $destination
+ }
+
+ $real_mode = $mode ? {
+ 'absent' => 0640,
+ default => $mode
+ }
+
+ $real_owner = $owner ? {
+ 'absent' => root,
+ default => $owner
+ }
+
+ $real_group = $group ? {
+ 'absent' => 0,
+ default => $group
+ }
+
+ # 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 => $real_owner, group => $real_group, mode => $real_mode;
+ }
+
+ # 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],
+ }
+}