aboutsummaryrefslogtreecommitdiffstats
path: root/modules/sympa/manifests/init.pp
blob: 50409bcc69d2d3472aa5e813ae71f277339d3d76 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
class sympa {
    class variable {
        $vhost = "ml.$domain"
    }

    class server inherits variable {
        # perl-CGI-Fast is needed for fast cgi
        # perl-Socket6 is required by perl-IO-Socket-SSL
        #  (optional requirement)
        $package_list = ['sympa', 'sympa-www', 'perl-CGI-Fast',
                         'perl-Socket6']
    
        package { $package_list:
            ensure => installed;
        }
    
        # sympa script start 5 differents script, I am not
        # sure that puppet will correctly handle this
        service { "sympa":
            ensure => running,
            hasstatus => true,
            subscribe => [ Package["sympa"], File['/etc/sympa/sympa.conf']]
        }
    
        $password = extlookup("sympa_password",'x')
        $ldap_passwd = extlookup("sympa_ldap",'x')
    
        @@postgresql::user { 'sympa':
            password => $password,
        }
    
        file { '/etc/sympa/sympa.conf':
            ensure => present,
    	# should be cleaner to have it root owned, but puppet do not support acl
    	# and in any case, config will be reset if it change
            owner => sympa,
            group => apache,
            mode => 640,
            content => template("sympa/sympa.conf")
        }
    
        file { '/etc/sympa/auth.conf':
            ensure => present,
            owner => root,
            group => root,
            mode => 644,
            content => template("sympa/auth.conf"),
            notify => Service['httpd']
        }
    
    
        include apache::mod_fcgid
        apache::webapp_other{"sympa":
             webapp_file => "sympa/webapp_sympa.conf",
        }
   
        apache::vhost_redirect_ssl { "$vhost": }
 
        apache::vhost_other_app { "$vhost":
            vhost_file => "sympa/vhost_ml.conf",
        }

        openssl::self_signed_cert{ "$vhost":
            directory => "/etc/ssl/apache/"
        }
    

        @@postgresql::database { 'sympa':
            description => "Sympa database",
            user => "sympa",
            require => Postgresql::User["sympa"]
        }
    
        subversion::snapshot { "/etc/sympa/web_tt2":
            source => "svn://svn.mageia.org/svn/web/templates/sympa/trunk"
        }

        file { ["/etc/sympa/lists_xml/",
                "/etc/sympa/scenari/",
                "/etc/sympa/data_sources/",
                "/etc/sympa/search_filters/"]:
            ensure => directory,
            owner => root,
            group => root,
            mode => 755,
        }

        define ldap_search_filter {
            file { "/etc/sympa/search_filters/ldap-$name.ldap":
                ensure => present,
                owner => root,
                group => root,
                mode => 755,
                content => template('sympa/group.ldap') 
            }
        }

        define ldap_group_datasource {
            file { "/etc/sympa/data_sources/ldap-$name.incl":
                ensure => present,
                owner => root,
                group => root,
                mode => 755,
                content => template('sympa/ldap_group.incl') 
            }
        }

        define scenario_sender_ldap_group {
            # TODO

        }

        define scenario_sender_email {
            # TODO
        }

        # add each group that could be used in a sympa ml either as 
        # - owner
        # - editor ( moderation )
        ldap_group_datasource { "mga-sysadm": }
        ldap_group_datasource { "mga-ml_moderators": }


        # directory that will hold the list data
        # i am not sure of the name ( misc, 09/12/10 )
        file { "/var/lib/sympa/expl/":
            ensure => directory,
            owner => sympa,
            group => root,
            mode => 755,
        }
    }

    define list($subject, 
                $profile = false, 
                $language = 'en',
                $reply_to = false,
                $sender_email = false,
                $sender_ldap_group = false,
                $subscriber_ldap_group = false,
                $public_archive = true ) {

        include sympa::variable

        $xml_file = "/etc/sympa/lists_xml/$name.xml"

        file { "$xml_file":
            owner => root,
            group => root,
            content => template('sympa/list.xml')    
        }

        exec { "sympa.pl --create_list --robot=$sympa::variable::vhost --input_file=$xml_file":
            refreshonly => true,
            subscribe => File["$xml_file"],
            before => File["/var/lib/sympa/expl/$name/config"],
        }

        file { "/var/lib/sympa/expl/$name/config":
            ensure => present,
            owner => sympa,
            group => sympa,
            mode => 750,
            content => template("sympa/config"), 
        }

        if $sender_ldap_group {
            if ! defined(Sympa::Server::Scenario_sender_ldap_group[$sender_ldap_group]) {
                sympa::server::scenario_sender_ldap_group { $sender_ldap_group: }
            }
        }

        if $sender_email {
            if ! defined(Sympa::Server::Scenario_sender_email[$sender_email]) {
                sympa::server::scenario_sender_email { $sender_email: }
            }
        }
        
        if $subscriber_ldap_group {
            if ! defined(Sympa::Server::Ldap_search_filter[$subscriber_ldap_group]) {
                sympa::server::ldap_search_filter { $subscriber_ldap_group: }
            }
        }
    }

#
#   various types of list that can be directly used
#
#
    define public_list($subject, $language = 'en') {
        list { $name:
            subject => $subject,
           # profile => "public",
            language => $language,
        }
    }

    # list where announce are sent by member of ldap_group
    # reply_to is set to $reply_to
    define announce_list_group($subject, $reply_to, $sender_ldap_group, $language = 'en') {
        # profile + scenario
        list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            reply_to => $reply_to,
            sender_ldap_group => $sender_ldap_group,
        }
 
    }


    # list where announce are sent by $email only 
    # reply_to is set to $reply_to    
    define announce_list_email($subject, $reply_to, $sender_email, $language = 'en') {
       list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            reply_to => $reply_to,
            sender_email => $sender_email,
        }
    }

    # list where people cannot subscribe, where people from $ldap_group receive
    # mail, with public archive
    define restricted_list($subject, $subscriber_ldap_group, $language = 'en') {
       list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            subscriber_ldap_group => $subscriber_ldap_group,
            sender_ldap_group => $subscriber_ldap_group,
        }
    }

    # same as restricted list, but anybody can post
    define restricted_list_open($subject, $subscriber_ldap_group, $language = 'en') {
       list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            subscriber_ldap_group => $subscriber_ldap_group,
            sender_ldap_group => $subscriber_ldap_group,
        }        
    }

    # list with private archive, restricted to member of $ldap_group
    define private_list($subject, $subscriber_ldap_group, $language ='en') {
       list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            subscriber_ldap_group => $subscriber_ldap_group,
            sender_ldap_group => $subscriber_ldap_group,
            public_archive => false,
        }
    }
    
    # list with private archive, restricted to member of $ldap_group
    # everybody can post 
    # used for contact alias
    define private_list_open($subject, $subscriber_ldap_group, $language ='en') {
       list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            subscriber_ldap_group => $subscriber_ldap_group,
            public_archive => false,
        }
    }

    # same as private_list, but post are restricted to $email
    # ( scripting )
    define private_list_email($subject, $subscriber_ldap_group, $sender_email, $language ='en') {
        list{ $name:
            subject => $subject,
            profile => "",
            language => $language,
            subscriber_ldap_group => $subscriber_ldap_group,
            sender_email => $sender_email,
            public_archive => false,
        }
    }

}