summaryrefslogtreecommitdiff
path: root/manifests/config/file.pp
blob: d64945fed58abfa2af6b8009783536637d668c1c (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# manages a config file for lighty
define lighttpd::config::file(
  $ensure = present,
  $conf_source = 'absent',
  $content = 'absent'
){
  file{"${lighttpd::conf_dir}/${name}.conf":
    ensure  => $ensure,
    require => Package['lighttpd'],
    notify  => Service['lighttpd'],
    owner   => 'root',
    group   => 0,
    mode    => '0644';
  }

  case $::operatingsystem {
    centos,redhat,fedora: {
      file_line{$name:
        ensure  => $ensure,
        path    => "${lighttpd::conf_dir}/config.conf",
        line    => "include \"${lighttpd::conf_dir_name}/${name}.conf\"",
        notify  => Service['lighttpd'],
      }
    }
    debian,ubuntu: {
      $link_ensure = $ensure ? {
        'present' => 'link',
        default   => $ensure
      }
      file{"/etc/lighttpd/conf-enabled/${name}.conf":
        ensure  => $link_ensure,
        target  => "${lighttpd::conf_dir}/${name}.conf",
        require => Package['lighttpd'],
        notify  => Service['lighttpd'];
      }
    }
  }

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