summaryrefslogtreecommitdiff
path: root/manifests/config/file.pp
blob: 3b889ca544f9bd92dfa589e13df8c7af08690abc (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
65
66
67
# deploy apache configuration file
# by default we assume it's a global configuration file
define apache::config::file(
    $ensure = present,
    $type = 'global',
    $source = 'absent',
    $content = 'absent',
    $destination = 'absent'
){
    case $type {
        'include': { $confdir = 'include.d' }
        'global': { $confdir = 'conf.d' }
        default: { fail("Wrong config file type specified for ${name}") }
    }
    $real_destination = $destination ? {
        'absent' => $operatingsystem ? {
            centos => "${apache::centos::config_dir}/${confdir}/${name}",
            gentoo => "${apache::gentoo::config_dir}/${name}",
            debian => "${apache::debian::config_dir}/${confdir}/${name}",
            ubuntu => "${apache::ubuntu::config_dir}/${confdir}/${name}",
            openbsd => "${apache::openbsd::config_dir}/${confdir}/${name}",
            default => "/etc/apache2/${confdir}/${name}",
        },
        default => $destination
    }
    file{"apache_${name}":
        ensure => $ensure,
        path => $real_destination,
        notify => Service[apache],
        owner => root, group => 0, mode => 0644;
    }
    if $ensure == 'present' {
      case $content {
        'absent': {
            $real_source = $source ? {
                'absent' => [
                    "puppet:///modules/site-apache/${confdir}/${fqdn}/${name}",
                    "puppet:///modules/site-apache/${confdir}/${apache_cluster_node}/${name}",
                    "puppet:///modules/site-apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
                    "puppet:///modules/site-apache/${confdir}/${operatingsystem}/${name}",
                    "puppet:///modules/site-apache/${confdir}/${name}",
                    "puppet:///modules/apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
                    "puppet:///modules/apache/${confdir}/${operatingsystem}/${name}",
                    "puppet:///modules/apache/${confdir}/${name}"
                ],
                default => "puppet:///${source}",
            }
            File["apache_${name}"]{
                source => $real_source,
            }
        }
        default: {
            File["apache_${name}"]{
                content => $content,
            }
        }
      }
    }
    case $operatingsystem {
        openbsd: { info("no package dependency on ${operatingsystem} for ${name}") }
        default: {
            File["apache_${name}"]{
                require => Package[apache],
            }
        }
    }
}