aboutsummaryrefslogtreecommitdiffstats
path: root/modules/youri-check/manifests/init.pp
blob: 4eb5c51ff41af59bbb20bd1e4902d9cb0473ff8b (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class youri-check {
    class base {
        $vhost = "check.$domain"
        $user = 'youri'
        $config = '/etc/youri/cauldron.conf'
        $outdir = '/var/www/youri-check'
        $home = '/var/lib/youri'

        user { $user:
            comment => 'Youri Check',
            ensure => present,
            managehome => true,
            home => $home,
        }

	file { $home:
	    ensure => directory,
	    owner => $user,
	    group => $user,
	    mode => 755,
	}

        $pgsql_server = "$vhost"
        $pgsql_db = 'youri_check'
        $pgsql_user = 'youri'
        $pgsql_password = extlookup('youri_pgsql','x')
        
        file { "$config":
            ensure => present,
            owner => $user,
            mode => 640,
            content => template("youri-check/check.conf"),
        }
    }

    class check inherits base {
        package { ['perl-Youri-Media', 'youri-check', 'perl-DBD-Pg'] :
            ensure => installed
        }

        cron { 'check':
            command => "youri-check -c $config test",
            hour => "*",
            minute => 4,
            user => "$user",
	    environment => "MAILTO=root",
        }
    }

    class report inherits base {
        file { "$outdir":
            ensure => directory,
            owner => youri,
            mode => 755
        }

        postgresql::remote_user { $pgsql_user:
            password => $pgsql_password,
        }

        postgresql::remote_database { $pgsql_db:
            description => "Youri Check results",
            user => $pgsql_user,
        }

        package { ['youri-check', 'perl-DBD-Pg'] :
            ensure => installed
        }

        cron { 'check':
            command => "youri-check -c $config report",
            hour => "*",
            minute => 24,
            user => "$user",
        }

        apache::vhost_simple { $vhost:
            location => $outdir,
        }
    }
}