]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/resources/site.rb
Generate letsencrypt certificates for mediawiki sites
[chef.git] / cookbooks / mediawiki / resources / site.rb
1 #
2 # Cookbook Name:: mediawiki
3 # Resource:: mediawiki_site
4 #
5 # Copyright 2015, OpenStreetMap Foundation
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 actions :create, :update, :delete
21 default_action :create
22
23 attribute :name, :kind_of => String, :name_attribute => true
24 attribute :aliases, :kind_of => [String, Array]
25 attribute :directory, :kind_of => String
26 attribute :version, :kind_of => String, :default => "1.26"
27 attribute :database_name, :kind_of => String, :required => true
28 attribute :database_user, :kind_of => String, :required => true
29 attribute :database_password, :kind_of => String, :required => true
30 attribute :sitename, :kind_of => String, :default => "OpenStreetMap Wiki"
31 attribute :metanamespace, :kind_of => String, :default => "OpenStreetMap"
32 attribute :logo, :kind_of => String, :default => "$wgStylePath/common/images/wiki.png"
33 attribute :email_contact, :kind_of => String, :default => ""
34 attribute :email_sender, :kind_of => String, :default => ""
35 attribute :email_sender_name, :kind_of => String, :default => "MediaWiki Mail"
36 attribute :commons, :kind_of => [TrueClass, FalseClass], :default => true
37 attribute :skin, :kind_of => String, :default => "vector"
38 attribute :site_notice, :kind_of => [String, TrueClass, FalseClass], :default => false
39 attribute :site_readonly, :kind_of => [String, TrueClass, FalseClass], :default => false
40 attribute :admin_user, :kind_of => String, :default => "Admin"
41 attribute :admin_password, :kind_of => String, :required => true
42 attribute :ssl_enabled, :kind_of => [TrueClass, FalseClass], :default => false
43 attribute :private_accounts, :kind_of => [TrueClass, FalseClass], :default => false
44 attribute :private, :kind_of => [TrueClass, FalseClass], :default => false
45 attribute :recaptcha_public_key, :kind_of => String
46 attribute :recaptcha_private_key, :kind_of => String
47 attribute :extra_file_extensions, :kind_of => [String, Array], :default => []
48 attribute :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true
49
50 def after_created
51   notifies :reload, "service[apache2]" if reload_apache
52 end
53
54 def database_params
55   {
56     :host => "localhost",
57     :name => database_name,
58     :username => database_user,
59     :password => database_password
60   }
61 end
62
63 def mediawiki_params
64   {
65     :sitename => sitename,
66     :metanamespace => metanamespace,
67     :logo => logo,
68     :email_contact => email_contact,
69     :email_sender => email_sender,
70     :email_sender_name => email_sender_name,
71     :commons => commons,
72     :skin => skin,
73     :site_notice => site_notice,
74     :site_readonly => site_readonly,
75     :ssl_enabled => ssl_enabled,
76     :extra_file_extensions => extra_file_extensions,
77     :private_accounts => private_accounts,
78     :private => private
79   }
80 end