jtimberman / puppet

Public Puppet Configuration by The SANS Institute

This URL has Read+Write access

Joshua Timberman (author)
Wed Jun 18 08:46:57 -0700 2008
puppet / pmwiki / manifests / init.pp
49ff6d66 » Joshua Timberman 2008-06-03 first commit 1 # define pmwiki sets up a pmwiki instance in the specified directory.
2 # This resource assumes Apache and Httpd configuration as well.
3 #
4 # Variables used:
5 #
6 # $docroot: The DocumentRoot from the VirtualHost.
7 # $group: Group owner of the directories and files.
8 # $path: Path on the download server where we get pmwiki tarball from.
9 # $server: Web/FTP server where the pmwiki tarball is located.
10 # $version: Version of PmWiki to install.
11 #
12 # Example usage:
13 # pmwiki { "${hostname}-pmwiki":
14 # docroot => "/srv/www/pmwiki",
15 # group => "htdocs",
16 # path => "pub/pmwiki",
17 # server => "www.pmwiki.org",
18 # version => "2.2.0-beta65",
19 # }
20
21 define pmwiki (
22 $docroot = '/srv/www/pmwiki',
23 $group = 'htdocs',
24 $path = 'pub/pmwiki',
25 $server = 'puppet',
26 $version = ''
27 ) {
28
29 Exec {
30 path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
31 cwd => "/srv/www",
32 require => File["/srv/www"],
33 }
34
35 File {
36 owner => "root",
37 group => "${group}",
38 }
39
40 exec {
41 "wget-pmwiki":
42 command => "wget http://${server}/${path}/pmwiki-${version}.tgz",
43 creates => "${docroot}-${version}.tgz";
44
45 "untar-pmwiki":
46 command => "tar --group ${group} -zxf ${docroot}-${version}.tgz",
47 unless => "test -d ${docroot}-${version}",
48 require => Exec["wget-pmwiki"];
49 }
50
51 file {
52 "${docroot}-${version}":
53 recurse => true,
54 require => Exec["untar-pmwiki"];
55
56 "${docroot}":
57 ensure => "${docroot}-${version}",
58 require => File["${docroot}-${version}"];
59
60 ["${docroot}/wiki.d", "${docroot}/uploads"]:
61 ensure => directory,
62 mode => "2775",
63 require => File["${docroot}"];
64
65 "${docroot}/index.php":
66 content => "<?php include('pmwiki.php');",
67 require => File["${docroot}"];
68
69 "${docroot}/.htaccess":
70 mode => "644",
71 source => "puppet:///pmwiki/htaccess",
72 require => File["${docroot}"];
73 }
74 }
75
76 # define pmwiki::sync sets up the script and cron entry to copy the
77 # pmwiki directory tree via rsync from one node to the other.
78 #
79 # Variables used:
80 # $dest: Destination node, passed to the rsync script in cron entry.
81 # $dir: Directory to copy, passed to the rsync script in cron entry.
82 #
83 # Example usage:
84 # pmwiki::sync { "${hostname}":
85 # dest => "web1f",
86 # dir => "/srv/www/pmwiki",
87 # }
88 define pmwiki::sync ($dest = '', $dir = '') {
89 file { "/usr/local/bin/rsync-pmwiki":
90 ensure => present,
91 mode => 0755,
92 source => "puppet:///pmwiki/rsync-pmwiki",
93 }
94 cron { "rsync-pmwiki":
95 command => "/usr/local/bin/rsync-pmwiki ${dest} ${dir}",
96 minute => "*/15",
97 }
98 }
99 # vi:syntax=puppet:filetype=puppet:ts=4:et:
100 # EOF