summaryrefslogtreecommitdiff
path: root/manifests/config/file.pp
blob: c7038340f5cb56fa7ac15a1dfe1608076bab9925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
define lighttpd::config::file(
  $ensure = present,
  $conf_source = 'absent',
  $content = 'absent'
){
  $conf_dir = $::operatingsystem ? {
    debian => '/etc/lighttpd/conf-available',
    ubuntu => '/etc/lighttpd/conf-available',
    default => '/etc/lighttpd/conf.d'
  }
  file{"${conf_dir}/${name}.conf":
    ensure => $ensure,
    notify => Service['lighttpd'],
    owner => root, group => 0, mode => 0644;
  }

  case $content {
    'absent': {
      File["${conf_dir}/${name}.conf"]{
        source => $conf_source ? {
          'absent'  => [
            "puppet:///modules/site_lighttpd/conf.d/${::fqdn}/${name}.conf",
            "puppet:///modules/site_lighttpd/conf.d/${lighttpd::cluster_node}/${name}.conf",
            "puppet:///modules/site_lighttpd/conf.d/${::operatingsystem}.${::lsbdistcodename}/${name}.conf",
            "puppet:///modules/site_lighttpd/conf.d/${::operatingsystem}/${name}.conf",
            "puppet:///modules/site_lighttpd/conf.d/${name}.conf",
            "puppet:///modules/lighttpd/conf.d/${name}.conf",
            "puppet:///modules/lighttpd/conf.d/${::operatingsystem}.${::lsbdistcodename}/${name}.conf",
            "puppet:///modules/lighttpd/conf.d/${::operatingsystem}/${name}.conf",
            "puppet:///modules/lighttpd/conf.d/${name}.conf"
          ],
        default => "puppet:///$conf_source",
        }
      }
    }
    default: {
      File["${conf_dir}/${name}.conf"]{
        content => $content,
      }
    }
  }
}