# 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])
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
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]
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
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
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
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
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
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
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
template "mw-ext-CirrusSearch.inc.php.erb"
end
- #OSM specifc extensions
+ # OSM specifc extensions
mediawiki_extension "osmtaginfo" do
site name
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"
user node[:mediawiki][:user]
group node[:mediawiki][:group]
end
-
end