From b4f387dd6b51418fc830b25acfafceb7e75fe1d0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 26 Mar 2015 21:49:49 +0000 Subject: [PATCH] Convert mediawiki_extension to an LWRP --- .../definitions/mediawiki_extension.rb | 84 ------------- cookbooks/mediawiki/providers/extension.rb | 113 ++++++++++++++++++ cookbooks/mediawiki/resources/extension.rb | 42 +++++++ 3 files changed, 155 insertions(+), 84 deletions(-) delete mode 100644 cookbooks/mediawiki/definitions/mediawiki_extension.rb create mode 100644 cookbooks/mediawiki/providers/extension.rb create mode 100644 cookbooks/mediawiki/resources/extension.rb diff --git a/cookbooks/mediawiki/definitions/mediawiki_extension.rb b/cookbooks/mediawiki/definitions/mediawiki_extension.rb deleted file mode 100644 index 764a59832..000000000 --- a/cookbooks/mediawiki/definitions/mediawiki_extension.rb +++ /dev/null @@ -1,84 +0,0 @@ -# -# Cookbook Name:: mediawiki -# Definition:: mediawiki_extension -# -# Copyright 2013, OpenStreetMap Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -define :mediawiki_extension, :action => [:enable], :variables => {} do - name = params[:name] - site = params[:site] - mediawiki_directory = node[:mediawiki][:sites][site][:directory] - extension_directory = "#{mediawiki_directory}/extensions/#{name}" - source = params[:source] - template = params[:template] - template_variables = params[:variables] - - if source - remote_directory extension_directory do - cookbook "mediawiki" - source source - owner node[:mediawiki][:user] - group node[:mediawiki][:group] - mode 0755 - files_owner node[:mediawiki][:user] - files_group node[:mediawiki][:group] - files_mode 0755 - end - else - repository = params[:repository] || "git://github.com/wikimedia/mediawiki-extensions-#{name}.git" - version = params[:version] || node[:mediawiki][:sites][site][:version] - tag = params[:tag] - if tag - reference = "refs/tags/#{tag}" - else - reference = "refs/heads/REL#{version}".tr(".", "_") - end - - git extension_directory do - action :sync - repository repository - reference reference - # depth 1 - enable_submodules true - user node[:mediawiki][:user] - group node[:mediawiki][:group] - ignore_failure repository.start_with?("git://github.com/wikimedia/mediawiki-extensions") - notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]" - end - end - - if template # ~FC023 - template "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do - cookbook "mediawiki" - source template - user node[:mediawiki][:user] - group node[:mediawiki][:group] - mode 0664 - variables template_variables - notifies :create, "template[#{mediawiki_directory}/LocalSettings.php]" - end - end - - file "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do - action :create_if_missing - user node[:mediawiki][:user] - group node[:mediawiki][:group] - mode 0664 - content " String, :name_attribute => true +attribute :site, :kind_of => String, :required => true +attribute :source, :kind_of => String +attribute :template, :kind_of => String +attribute :variables, :kind_of => Hash, :default => {} +attribute :version, :kind_of => String +attribute :repository, :kind_of => String +attribute :tag, :kind_of => String +attribute :update_site, :kind_of => [TrueClass, FalseClass], :default => false + +def after_created + if update_site + notifies :update, "mediawik_site[site]" + else + site_directory = node[:mediawiki][:sites][site][:directory] + + notifies :create, "template[#{site_directory}/LocalSettings.php]" + notifies :run, "execute[#{site_directory}/maintenance/update.php]" + end +end -- 2.39.5