aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mediawiki/manifests/init.pp
blob: 490895844c9e1c4b7bd80c7f8014051419b0eaed (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class mediawiki {
    class config(
	$pgsql_password,
	$secretkey,
	$ldap_password,
	$vhost = "wiki.$domain"
    ) { }

    class base inherits config {

        $root = "/srv/wiki/"

        include apache::mod_php

        package { ['mediawiki-minimal','mediawiki-ldapauthentication'] :
            ensure => installed,
        }

        file { $root:
            ensure => directory,
        }
      
        file { "/usr/local/bin/init_wiki.php":
             ensure => present,
             owner => root,
             group => root,
             mode => 755,
             source => 'puppet:///modules/mediawiki/init_wiki.php',
        }
 
        $user = "mediawiki"
 
        postgresql::remote_user { $user:
            password => sprintf('%s', $config::pgsql_password),
        }

        # TODO create the ldap user   

	apache::vhost_redirect_ssl { $vhost: }

        apache::vhost_base { "ssl_$vhost":
            location => $root,
            use_ssl => true,
            vhost => "wiki.$domain",
            content => template("mediawiki/wiki_vhost.conf"),
        }



        # add index.php
    }        

    # do wiki basic installation

    define instance($title, $wiki_settings = '') {

        include mediawiki::base

        $path = $name
        $lang = $name
        $wiki_root = "$mediawiki::base::root/$path"
        $db_name = "mediawiki_$name"
        $db_user = "$mediawiki::base::user"
        $db_password = "$mediawiki::config::pgsql_password"
        $secret_key = "$mediawiki::config::secretkey"

        file { "$wiki_root":
            ensure => directory 
        }

        exec { "wikicreate $name":
            command => "mediawiki-create $wiki_root",
            cwd => "$mediawiki::base::root",
            require => [File["$wiki_root"],Package['mediawiki-minimal']],
            creates => "$wiki_root/index.php",
        }

        postgresql::remote_database { "$db_name":
            user => $db_user,
            callback_notify => Exec["deploy_db $name"], 
        }

        exec { "deploy_db $name":
            command => "php /usr/local/bin/init_wiki.php $wiki_root", 
            refreshonly => true,
            onlyif => "test -d $wiki_root/config",
        }
        $ldap_password = $config::ldap_password

        file { "$wiki_root/LocalSettings.php":
            ensure => present,
	    owner => apache,
	    mode => 600,
            content => template("mediawiki/LocalSettings.php"),
            # if LocalSettings is created first, the wikicreate script
            # do not create a confg directory, and so it doesn't trigger deploy_db exec
            require => Exec["wikicreate $name"],
        }
    }
}