jtimberman / puppet

Public Puppet Configuration by The SANS Institute

Joshua Timberman (author)
Wed Jun 18 08:46:57 -0700 2008
puppet / pmwiki / manifests / init.pp
100644 101 lines (89 sloc) 2.947 kb
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# define pmwiki sets up a pmwiki instance in the specified directory.
# This resource assumes Apache and Httpd configuration as well.
#
# Variables used:
#
# $docroot: The DocumentRoot from the VirtualHost.
# $group: Group owner of the directories and files.
# $path: Path on the download server where we get pmwiki tarball from.
# $server: Web/FTP server where the pmwiki tarball is located.
# $version: Version of PmWiki to install.
#
# Example usage:
# pmwiki { "${hostname}-pmwiki":
# docroot => "/srv/www/pmwiki",
# group => "htdocs",
# path => "pub/pmwiki",
# server => "www.pmwiki.org",
# version => "2.2.0-beta65",
# }
 
define pmwiki (
    $docroot = '/srv/www/pmwiki',
    $group = 'htdocs',
    $path = 'pub/pmwiki',
    $server = 'puppet',
    $version = ''
) {
    
    Exec {
        path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        cwd => "/srv/www",
        require => File["/srv/www"],
    }
    
    File {
        owner => "root",
        group => "${group}",
    }
    
    exec {
        "wget-pmwiki":
            command => "wget http://${server}/${path}/pmwiki-${version}.tgz",
            creates => "${docroot}-${version}.tgz";
 
        "untar-pmwiki":
            command => "tar --group ${group} -zxf ${docroot}-${version}.tgz",
            unless => "test -d ${docroot}-${version}",
            require => Exec["wget-pmwiki"];
    }
 
    file {
        "${docroot}-${version}":
            recurse => true,
            require => Exec["untar-pmwiki"];
        
        "${docroot}":
            ensure => "${docroot}-${version}",
            require => File["${docroot}-${version}"];
        
        ["${docroot}/wiki.d", "${docroot}/uploads"]:
            ensure => directory,
            mode => "2775",
            require => File["${docroot}"];
        
        "${docroot}/index.php":
            content => "<?php include('pmwiki.php');",
            require => File["${docroot}"];
        
        "${docroot}/.htaccess":
            mode => "644",
            source => "puppet:///pmwiki/htaccess",
            require => File["${docroot}"];
    }
}
 
# define pmwiki::sync sets up the script and cron entry to copy the
# pmwiki directory tree via rsync from one node to the other.
#
# Variables used:
# $dest: Destination node, passed to the rsync script in cron entry.
# $dir: Directory to copy, passed to the rsync script in cron entry.
#
# Example usage:
# pmwiki::sync { "${hostname}":
# dest => "web1f",
# dir => "/srv/www/pmwiki",
# }
define pmwiki::sync ($dest = '', $dir = '') {
    file { "/usr/local/bin/rsync-pmwiki":
        ensure => present,
        mode => 0755,
        source => "puppet:///pmwiki/rsync-pmwiki",
    }
    cron { "rsync-pmwiki":
        command => "/usr/local/bin/rsync-pmwiki ${dest} ${dir}",
        minute => "*/15",
    }
}
# vi:syntax=puppet:filetype=puppet:ts=4:et:
# EOF