X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/46d97368eb6034f2eb95d5a8400bd4bf6faf4ed2..078fb0e99fcd071b8617ccbb8aae52566e7bb122:/cookbooks/mediawiki/definitions/mediawiki_site.rb diff --git a/cookbooks/mediawiki/definitions/mediawiki_site.rb b/cookbooks/mediawiki/definitions/mediawiki_site.rb index d6a1ab773..8b0ddaccb 100644 --- a/cookbooks/mediawiki/definitions/mediawiki_site.rb +++ b/cookbooks/mediawiki/definitions/mediawiki_site.rb @@ -17,10 +17,10 @@ # limitations under the License. # -define :mediawiki_site, :action => [ :create, :enable ] do +define :mediawiki_site, :action => [:create, :enable] do name = params[:name] - #/etc/cron.d names cannot contain a dot + # /etc/cron.d names cannot contain a dot cron_name = name.tr(".", "_") aliases = Array(params[:aliases]) @@ -38,28 +38,29 @@ define :mediawiki_site, :action => [ :create, :enable ] do mediawiki_version = params[:version] || "1.22" mediawiki_reference = "refs/heads/REL#{mediawiki_version}".tr(".", "_") - passwords = data_bag_item("mediawiki", "passwords") - mediawiki = { - :directory => "#{site_directory}/w", - :site => name, - :sitename => params[:sitename] || "OpenStreetMap Wiki", - :metanamespace => params[:metanamespace] || "OpenStreetMap", - :logo => params[:logo] || "$wgStylePath/common/images/wiki.png", - :email_contact => params[:email_contact] || "", - :email_sender => params[:email_sender] || "", - :email_sender_name => params[:email_sender_name] || "MediaWiki Mail", - :commons => params[:commons] || TRUE, - :skin => params[:skin] || "vector", - :site_notice => params[:site_notice] || "", - :site_readonly => params[:site_readonly] || FALSE, - :site_admin_user => "Admin", - :site_admin_pw => passwords["mediawiki-admin-user"], - :enable_ssl => params[:enable_ssl] || FALSE, - :private => params[:private] || FALSE + :directory => "#{site_directory}/w", + :site => name, + :sitename => params[:sitename] || "OpenStreetMap Wiki", + :metanamespace => params[:metanamespace] || "OpenStreetMap", + :logo => params[:logo] || "$wgStylePath/common/images/wiki.png", + :email_contact => params[:email_contact] || "", + :email_sender => params[:email_sender] || "", + :email_sender_name => params[:email_sender_name] || "MediaWiki Mail", + :commons => params[:commons] || TRUE, + :skin => params[:skin] || "vector", + :site_notice => params[:site_notice] || "", + :site_readonly => params[:site_readonly] || FALSE, + :site_admin_user => "Admin", + :site_admin_pw => params[:admin_password], + :enable_ssl => params[:enable_ssl] || FALSE, + :private_accounts => params[:private_accounts] || FALSE, + :private => params[:private] || FALSE, + :recaptcha_public => params[:recaptcha_public_key], + :recaptcha_private => params[:recaptcha_private_key] } -#---------------- + #---------------- node.set_unless[:mediawiki][:sites][name] = {} node.set[:mediawiki][:sites][name][:site_directory] = site_directory @@ -67,7 +68,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do node.set[:mediawiki][:sites][name][:version] = mediawiki_version node.set_unless[:mediawiki][:sites][name][:wgSecretKey] = random_password(64) -#---------------- + #---------------- mysql_user "#{database_params[:username]}@localhost" do password database_params[:password] @@ -80,21 +81,21 @@ define :mediawiki_site, :action => [ :create, :enable ] do ruby_block "rename-installer-localsettings" do action :nothing block do - ::File.rename("#{mediawiki[:directory]}/LocalSettings.php","#{mediawiki[:directory]}/LocalSettings-install.php") + ::File.rename("#{mediawiki[:directory]}/LocalSettings.php", "#{mediawiki[:directory]}/LocalSettings-install.php") end end execute "#{mediawiki[:directory]}/maintenance/install.php" do action :nothing - #Use metanamespace as Site Name to ensure correct set namespace + # Use metanamespace as Site Name to ensure correct set namespace command "php maintenance/install.php --server '#{name}' --dbtype 'mysql' --dbname '#{database_params[:name]}' --dbuser '#{database_params[:username]}' --dbpass '#{database_params[:password]}' --dbserver '#{database_params[:host]}' --scriptpath /w --pass '#{mediawiki[:site_admin_pw]}' '#{mediawiki[:metanamespace]}' '#{mediawiki[:site_admin_user]}'" cwd mediawiki[:directory] user node[:mediawiki][:user] group node[:mediawiki][:group] not_if do - File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php") + File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php") end - notifies :create, 'ruby_block[rename-installer-localsettings]', :immediately + notifies :create, "ruby_block[rename-installer-localsettings]", :immediately end execute "#{mediawiki[:directory]}/maintenance/update.php" do @@ -105,38 +106,38 @@ define :mediawiki_site, :action => [ :create, :enable ] do group node[:mediawiki][:group] end - directory "#{site_directory}" do + directory site_directory do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - directory "#{mediawiki[:directory]}" do + directory mediawiki[:directory] do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0775 end - git "#{mediawiki[:directory]}" do + git mediawiki[:directory] do action :sync repository mediawiki_repository reference mediawiki_reference - #depth 1 + # depth 1 user node[:mediawiki][:user] group node[:mediawiki][:group] - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end - #Safety catch if git doesn't update but install.php hasn't run + # Safety catch if git doesn't update but install.php hasn't run ruby_block "catch-installer-localsettings-run" do block do # end not_if do - File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php") + File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php") end - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/install.php]", :immediately action :create end @@ -164,12 +165,8 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner node[:mediawiki][:user] group node[:mediawiki][:group] mode 0664 - variables({ - :name => name, - :database_params => database_params, - :mediawiki => mediawiki - }) - notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/update.php") + variables :name => name, :database_params => database_params, :mediawiki => mediawiki + notifies :run, "execute[#{mediawiki[:directory]}/maintenance/update.php]" end template "/etc/cron.d/mediawiki-#{cron_name}" do @@ -178,11 +175,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner "root" group "root" mode 0644 - variables({ - :name => name, - :directory => site_directory, - :user => node[:mediawiki][:user] - }) + variables :name => name, :directory => site_directory, :user => node[:mediawiki][:user] end template "/etc/cron.daily/mediawiki-#{cron_name}-backup" do @@ -191,23 +184,21 @@ define :mediawiki_site, :action => [ :create, :enable ] do owner "root" group "root" mode 0700 - variables({ - :name => name, - :directory => site_directory, - :database_params => database_params - }) + variables :name => name, :directory => site_directory, :database_params => database_params end - #MediaWiki Default Extension + # MediaWiki Default Extension mediawiki_extension "Cite" do site name - template "mw-ext-Cite.inc.php.erb" + template "mw-ext-Cite.inc.php.erb" end mediawiki_extension "ConfirmEdit" do site name template "mw-ext-ConfirmEdit.inc.php.erb" + variables :public_key => mediawiki[:recaptcha_public], + :private_key => mediawiki[:recaptcha_private] end mediawiki_extension "Gadgets" do @@ -273,7 +264,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do end # MediaWiki Language Extension Bundle - #fixme should automatically resolve tag + # FIXME: should automatically resolve tag mw_lang_ext_bundle_tag = "2014.09" mediawiki_extension "Babel" do @@ -299,25 +290,21 @@ define :mediawiki_site, :action => [ :create, :enable ] do tag mw_lang_ext_bundle_tag end - #LocalisationUpdate Update Cron - #template "/etc/cron.d/mediawiki-#{name}-LocalisationUpdate" do - # cookbook "mediawiki" - # source "mediawiki-LocalisationUpdate.cron.erb" - # owner "root" - # group "root" - # mode 0755 - # variables({ - # :name => name, - # :directory => site_directory, - # :user => node[:mediawiki][:user] - # }) - #end - - #mediawiki_extension "Translate" do - # site name - # template "mw-ext-Translate.inc.php.erb" - # tag mw_lang_ext_bundle_tag - #end + # LocalisationUpdate Update Cron + # template "/etc/cron.d/mediawiki-#{name}-LocalisationUpdate" do + # cookbook "mediawiki" + # source "mediawiki-LocalisationUpdate.cron.erb" + # owner "root" + # group "root" + # mode 0755 + # variables :name => name, :directory => site_directory, :user => node[:mediawiki][:user] + # end + + # mediawiki_extension "Translate" do + # site name + # template "mw-ext-Translate.inc.php.erb" + # tag mw_lang_ext_bundle_tag + # end mediawiki_extension "UniversalLanguageSelector" do site name @@ -353,7 +340,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do template "mw-ext-CirrusSearch.inc.php.erb" end - #OSM specifc extensions + # OSM specifc extensions mediawiki_extension "osmtaginfo" do site name @@ -400,14 +387,11 @@ define :mediawiki_site, :action => [ :create, :enable ] do cookbook "mediawiki" template "apache.erb" directory site_directory - variables({ - :aliases => aliases, - :mediawiki => mediawiki - }) + variables :aliases => aliases, :mediawiki => mediawiki notifies :reload, "service[apache2]" end - #Fixme - Needs to run once + # FIXME: needs to run once execute "#{mediawiki[:directory]}/extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php" do action :nothing command "php extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php" @@ -415,5 +399,4 @@ define :mediawiki_site, :action => [ :create, :enable ] do user node[:mediawiki][:user] group node[:mediawiki][:group] end - end